#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using vi = vector; template bool chmax(T1 &a, const T2 b) {if (a < b) {a = b; return true;} else return false; } template bool chmin(T1 &a, const T2 b) {if (a > b) {a = b; return true;} else return false; } signed main() { int n;cin>>n; map mp; rep(i,n){ int a;cin>>a; mp[a]++; } set st; for(auto &e:mp){ e.second/=2; if(e.second!=0)st.insert(e.first); } int ans = 0; while(st.count(ans))ans++; cout<