Party codeforces problem

sir in 115A Party problem of codeforces . Iam using set stl in the problem but its giving wrong answer. May i know why.

MY CODE IS HERE:

#include <bits/stdc++.h>
#define ll long long int
#define vi vector
#define vll vector
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define f first
#define s second
using namespace std;

int main()
{
int n;
cin >> n;
set a;
for (int i = 1; i <=n; ++i)
{
int x;
cin >> x;
a.insert(x);
}
int ans = -1;
for(int i : a){
ans = max(ans, i);
}

cout << ans +1 << endl;
return 0;

}