#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define db double #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n;cin>>n; vcv(2e5,0); rep(i,n){ int a;cin>>a; v[a]++; } bool bo=true; int ans; for(int i=0;i<(int)2e5;i++){ if(v[i]==0){ ans=i; break; } if(bo&&v[i]==1){ bo=false; continue; } if(!bo&&v[i]==1){ ans=i;break; } } if(n&1)if(ans==n/2+1)ans--; cout<