直接都统计一次,出现两次就是大于1呗……
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<deque>
#include<functional>
#include<iterator>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#define CPY(A, B) memcpy(A, B, sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double OO = 1e20;
const double PI = acos (-1.0);
int dx[]= {0,1,1,1,0,-1,-1,-1};
int dy[]= {1,1,0,-1,-1,-1,0,1};
using namespace std;
int n,cnt[1010];
int main() {
while (cin >> n) {
memset (cnt,0,sizeof (cnt) );
int a;
for (int i=0; i<=n; i++) {
scanf ("%d",&a);
cnt[a]++;
}
int ans=0;
for (int i=1; i<=n; i++) {
if (cnt[i]>1) { ans=i; }
}
printf ("%d\n",ans);
}
return 0;
}