reverse(char ch[], int left, int right) ///翻转字符串
{if (left < right) {reverse(ch, left +1, right -1);
int t = ch[left]; ch[left] = ch[right];ch[right] =t;
}else return 0;}
reverse (ch, left, strlen(ch)-1);
map<ll, int> mp; // <shuzi, cishu>
int main ()
{
ios::sync_with_stdio(0);
int n;ll num; cin >> n;
for (int i=1; i<= n; i++) {
ll tmp; cin >> tmp;
mp[tmp] ++;
}
map <ll, int>::iterator it;
for (it = mp.begin(); it!=mp.end(); it ++)
{
num = (*it).first;
int cnt = (*it).second;
if (cnt %(num + 1) == 0){
mp[num+1] =mp[num+1] + cnt/(num+1);
}
else {
break;
}
}
cout << num;