#include #include using namespace std; int main(){ int n;cin>>n; vector A(110000); for(int i = 0; n > i; i++){ int x;cin>>x; A[x]++; } bool am = false; bool lck = false; int i = 0; while(true){ if(A[i] == 1 && (i+1)*2 <= n && !lck){ lck = true; }else if(A[i] < 2){ cout << i << endl; return 0; } i++; } }