#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0, tmp=0;
    ll smas[(ll)1e6] {};
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> smas[i];
    }
    sort(smas, smas+n+2);
    for (int i=1; i<=n; i++){
        if (smas[i]>=i){
            smas[i]=tmp+1;
            tmp++;
        }
        else
            tmp=smas[i];
    }
    cout << smas[n]+1;

    fin.close();
    fout.close();
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}
ll smas[(ll)1e7] {};

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0, tmp=0;
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> smas[i];
    }
    sort(smas, smas+n+1);
    for (int i=1; i<=n; i++){
        if (smas[i]>=i){
            smas[i]=tmp+1;
            tmp++;
        }
        tmp=smas[i];
        //cout << smas[i]  << ' ' ;
    }
    cout << smas[n]+1 << endl;

    fin.close();
    fout.close();
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0;
    multiset<ll> smas;
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> m;
        smas.insert(m);
    }
    ll i=1;
    for (auto&s:smas){
        if (s<i){
            cout << i+1;
            return 0;
        }
        i++;
    }
    cout << n+1;

    fin.close();
    fout.close();
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0, tmp=0;
    ll smas[(ll)1e6] {};
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> smas[i];
    }
    sort(smas+1, smas+n+1);
    for (int i=1; i<=n; i++){
        if (smas[i]>i){
            smas[i]=tmp+1;
            tmp++;
        }
        else
            tmp=smas[i];
    }
    cout << smas[n]+1;

    fin.close();
    fout.close();
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0, tmp=0;
    ll smas[(ll)1e6] {};
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> smas[i];
    }
    sort(smas, smas+n+1);
    for (int i=1; i<=n; i++){
        if (smas[i]>i){
            smas[i]=tmp+1;
            tmp++;
        }
        else
            tmp=smas[i];
    }
    cout << smas[n]+1;

    fin.close();
    fout.close();
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}
ll smas[(ll)1e7] {};

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0, tmp=0;
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> smas[i];
    }
    sort(smas, smas+n+1);
    for (int i=1; i<=n; i++){
        if (smas[i]>tmp){
            smas[i]=tmp+1;
            tmp++;
        }
        //cout << smas[i]  << ' ' ;
    }
    cout << tmp+1 << endl;

    fin.close();
    fout.close();
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (long long i=0; i<n; i++)
#define eps 1e-9

using namespace std;

typedef long long ll;

double sqr(double a){
    return a*a;
}
bool doubleEqual(double a, double b){
    return fabs(a-b)<1e-9;
}
bool doubleLessOrEqual(double a, double b){
    return a<b || doubleEqual(a, b);
}
bool doubleLess(double a, double b){
    return a<b && !doubleEqual(a, b);
}
bool doubleGreaterOrEqual(double a, double b){
    return a>b || doubleEqual(a, b);
}
bool doubleGreater(double a, double b){
    return a>b && !doubleEqual(a, b);
}
double mySqrt(double a){
    if (doubleLess(a,0)) throw "sqrt(-1)";
    if (a<0) return 0;
    return sqrt(a);
}

struct Point{
    double x, y;
    Point(): x(0), y(0) {}
    Point(double x, double y): x(x), y(y) {}
    void scan(){
        scanf("%lf %lf", &x, &y);
    }
    void print() const{
        printf("%.10lf %.10lf\n", x, y);
    }
    Point operator+(const Point &p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(const Point &p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    Point operator*(double k) const {
        return Point(x*k, y*k);
    }
    Point operator/(double k) const {
        return Point(x/k, y/k);
    }
    double operator%(const Point &p) const {
        return x*p.x+y*p.y;
    }
    double operator*(const Point &p) const {
        return x*p.y-y*p.x;
    }
    double length() const {
        return mySqrt(*this % *this);
    }
    double distTo(const Point &p) const {
        return (*this -p).length();
    }
    double distTo(const Point &A, const Point &B) const {
        double d=A.distTo(B);
        if (doubleEqual(d,0)){
            throw "A = B";
        }
        double s = (*this - A) * (*this - B);
        return fabs(s)/d;
    }
    Point normalize(double k=1) const {
        double len = length();
        if(doubleEqual(len, 0)) {
            if (doubleEqual(k, 0)){
                return Point();

            }
            throw "zero-size vector";
        }
        return *this*(k/len);
    }
    Point getH(const Point &A, const Point&B) const {
        Point C = *this;
        Point v = B - A;
        Point u = C - A;
        double k=v%u/v.length();
        v=v.normalize(k);
        Point H=A+v;
        return H;
    }
    Point rotate() const {
        return Point(-y, x);
    }
    Point rotate(double alpha) const {
        return rotate(cos(alpha), sin(alpha));
    }
    Point rotate(double cosa, double sina) const {
        Point v = *this;
        Point u = v.rotate();
        Point w = v*cosa + u*sina;
        return w;
    }
    bool isZero() const{
        return doubleEqual(x, 0) && doubleEqual(y, 0);
    }
    bool isOnline(const Point &A, const Point &B) const {
        return doubleEqual((A-*this)*(B-*this), 0);
    }
    bool isInSegment(const Point &A, const Point &B) const {
        return doubleLessOrEqual((A-*this)%(B-*this), 0);
    }
    bool isInSegmentStricly(const Point &A, const Point &B) const {
        return doubleLess((A-*this)%(B-*this), 0);
    }
    double getAngle() const {
        return atan2(y, x);
    }
    double getAngle(Point u) const {
        return atan2(*this*u, *this%u);
    }
};

int getIntersection(const Point &A, const Point &B, const Point &C, const Point &D, Point &O) {
    Point v = B-A;
    double s1 = (C-A)*(D-A);
    double s2 = (D-B)*(C-B);
    double s = s1+s2;
    if (doubleEqual(s, 0)){
        if (!A.isOnline(C,D))
            return 0;
        return 2;
    }
    v = v/s;
    v = v*s1;
    O = A+v;
    return 1;
}

int getIntersection(const Point &A, double rA, const Point &B, double rB, Point &M, Point &N){
    double d=A.distTo(B);
    if (doubleLess(rA+rB, d) || doubleLess(d, fabs(rA-rB))){
        return 0;
    }
    double a = (sqr(rA)-sqr(rB) + sqr(d))/2/d;
    double h=mySqrt(sqr(rA)-sqr(a));
    Point v = B-A;
    Point u = v.rotate();
    v = v.normalize(a);
    u = u.normalize(h);
    Point H=A+v;
    M=H+u;
    N=H-u;
    if (u.isZero())
        return 1;
    return 2;
}

int getIntersection(const Point &A, const Point &B, const Point &O, double r, Point &M, Point &N){
    double h = O.distTo(A,B);
    if (doubleLess(r, h)){
        return 0;
    }
    Point H=O.getH(A,B);
    Point v=B-A;
    double k=mySqrt(sqr(r)-sqr(h));
    v=v.normalize(k);
    M=H+v;
    N=H-v;
    if(v.isZero())
        return 1;
    return 2;
}

struct cmp{
    bool operator()(const string &a, const string &b){
        return a+b<b+a;
    }
};

ll GCD(ll a, ll b){
    return (!b?a:GCD(b, a%b));
}

ll POW(ll a, ll b){
    return (!b?1:b==1?a:b%2?POW(a,b>>1)*POW(a,b>>1)*a:POW(a,b>>1)*POW(a,b>>1));
}

int main(){
    ifstream fin("file.in");
    ofstream fout("file.out");
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    fin.sync_with_stdio(false);
    fout.sync_with_stdio(false);

    ll n, m, res=0, tmp=0;
    ll smas[(ll)1e7] {};
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> smas[i];
    }
    sort(smas, smas+n+1);
    for (int i=1; i<=n; i++){
        if (smas[i]>=i){
            smas[i]=tmp+1;
            tmp++;
        }
        else
            tmp=smas[i];
        cout << smas[i]  << ' ' ;
    }
    cout << smas[n]+1 << endl;

    fin.close();
    fout.close();
    return 0;
}


#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << (n) << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int main() {
  omajinai;
  int n; cin >> n;
  vector<int> num_v(n);
  rep(i, n) {
  	cin >> num_v[i];
  }
  sort(all(num_v));

  int cur = 1; // index + 1
  int count = 0;

  while (cur <= n) {
  	if (num_v[cur - 1] >= cur) {
		cur += 1;
		count += 1;
	} else {
		cout << num_v[cur - 1] + (n - cur) + 1 << endl;
		return 0; // n - cur: how many left
 	}
  }

  if (cur > n) {
  	cout << cur << endl;
  }

  return 0;
}


#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << (n) << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int main() {
  omajinai;
  int n; cin >> n;
  vector<int> num_v(n);
  rep(i, n) {
  	cin >> num_v[i];
  }

  sort(all(num_v));

  int cur = 1; // index + 1
  int count = 0;

  while (cur <= n) {
  	if (num_v[cur - 1] >= cur) {
		cur += 1;
		count += 1;
	} else {
		cout << num_v[cur - 1] + (n - cur) + 1 << endl;
		return 0; // n - cur: how many left
 	}
  }

  if (cur > n) {
  	cout << num_v[cur - 1] + 1 << endl;
  }
//  num_v[0] = 1;
//  rep(i, n - 1) {
//  	if (num_v[i + 1] > num_v[i]) {
//  		num_v[i + 1] = num_v[i] + 1;
//  	}
//  }
//  cout << num_v[n - 1] + 1 << endl;

//   return 0;
// }


#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << (n) << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int main() {
  omajinai;
  int n; cin >> n;
  vector<int> num_v(n);
  rep(i, n) {
  	cin >> num_v[i];
  }

  sort(all(num_v));

  int cur = 1; // index + 1
  int count = 0;

  while (cur <= n) {
  	if (num_v[cur - 1] >= cur) {
		cur += 1;
		count += 1;
	} else {
		cout << num_v[cur - 1] + (n - cur) + 1 << endl;
		return 0; // n - cur: how many left
 	}
  }

  if (cur > n) {
  	cout << num_v[n - 1] + 1 << endl;
  }
//  num_v[0] = 1;
//  rep(i, n - 1) {
//  	if (num_v[i + 1] > num_v[i]) {
//  		num_v[i + 1] = num_v[i] + 1;
//  	}
//  }
//  cout << num_v[n - 1] + 1 << endl;

  return 0;
}


#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << (n) << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int main() {
  omajinai;
  int n; cin >> n;
  vector<int> num_v(n);
  rep(i, n) {
  	cin >> num_v[i];
  }

  sort(all(num_v));

  int cur = 1; // index + 1
  int count = 0;

  while (cur <= n) {
  	if (num_v[cur - 1] >= cur) {
		cur += 1;
		count += 1;
	} else {
		cout << num_v[cur - 1] + (n - cur) + 1 << endl;
		return 0; // n - cur: how many left
 	}
  }

  if (cur > n) {
  	cout << num_v[cur - 1] + 1 << endl;
  }
//  num_v[0] = 1;
//  rep(i, n - 1) {
//  	if (num_v[i + 1] > num_v[i]) {
//  		num_v[i + 1] = num_v[i] + 1;
//  	}
//  }
//  cout << num_v[n - 1] + 1 << endl;

  return 0;
}


#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << (n) << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int main() {
  omajinai;
  int n; cin >> n;
  vector<int> num_v(n);
  rep(i, n) {
  	cin >> num_v[i];
  }

  sort(all(num_v));

  // int cur = 1; // index + 1
  // int count = 0;

 //  while (cur <= n) {
 //  	if (num_v[cur - 1] >= cur) {
	// 	cur += 1;
	// 	count += 1;
	// } else {
	// 	cout << num_v[cur - 1] + (n - cur) + 1 << endl;
	// 	return 0; // n - cur: how many left
 // 	}
 //  }

 //  if (cur > n) {
 //  	cout << cur << endl;
 //  }
 num_v[0] = 1;
 rep(i, n - 1) {
 	if (num_v[i + 1] > num_v[i]) {
 		num_v[i + 1] = num_v[i] + 1;
 	}
 }
 cout << num_v[n - 1] + 1 << endl;

  return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define N 1000005
#define INF 1000000000
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

vi v;

int n,m,a[N],b[N],ans;

int main()
{
	i(n);
    REP(i,0,n)
        {
        i(a[i]);
        b[a[i]]++;
    }
    REP(i,1,n+2)
        {
        if(b[i] == 0)
            {
            ans = i;
            break;
        }
    }
    printf("%d\n",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define N 1000005
#define INF 1000000000
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

vi v;

int n,m,a[N],b[N],ans;

int main()
{
	i(n);
    REP(i,0,n)
        {
        i(a[i]);
        if(a[i] > n)
            ans++;
    }
    printf("%d\n",n+1-ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define N 1000005
#define INF 1000000000
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

vi v;

int n,m,a[N],b[N],ans;

int main()
{
	i(n);
    REP(i,0,n)
        {
        i(a[i]);
        if(a[i] > n)
            ans++;
    }
    if(ans == 0)
        ans = -1;
    printf("%d\n",n-ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define il(n) scanf("%lld",&n)
#define N 1000005
#define INF 1000000000
#define MAX 1000000000000000000+1
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

int main()
{
    int n,tmp = 0;
    i(n);
    int a[n+1];
    REP(i,1,n+1)
        i(a[i]);
    sort(a+1,a+n+1);
    REP(i,1,n+1)
        {
        if(a[i] <= i)
            {
            tmp = min(a[i],i+1);
        }
        else
            a[i] = tmp+1;
    }
    printf("%d\n",a[n]+1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define il(n) scanf("%lld",&n)
#define N 1000005
#define INF 1000000000
#define MAX 1000000000000000000+1
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

int main()
{
    int n,tmp = 1;
    i(n);
    int a[n+1];
    REP(i,1,n+1)
        i(a[i]);
    sort(a+1,a+n+1);
    REP(i,1,n+1)
        {
        if(a[i] <= i)
            {
            tmp = min(a[i],i+1);
            if(i == n)
                tmp += 1;
            else
                continue;
        }
        else
            tmp += 1;
    }
    printf("%d\n",tmp);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define il(n) scanf("%lld",&n)
#define N 1000005
#define INF 1000000000
#define MAX 1000000000000000000+1
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

int main()
{
    int n,tmp = 1;
    i(n);
    int a[n+1];
    REP(i,1,n+1)
        i(a[i]);
    sort(a+1,a+n+1);
    REP(i,1,n+1)
        {
        if(a[i] <= i)
            {
            tmp = min(a[i],i+1);
        }
        else
            a[i] = tmp+1;
    }
    printf("%d\n",a[n]+1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define il(n) scanf("%lld",&n)
#define N 1000005
#define INF 1000000000
#define MAX 1000000000000000000+1
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= 0 ; --i)

int main()
{
    int n,tmp = 1;
    i(n);
    int a[n+1];
    REP(i,1,n+1)
        i(a[i]);
    sort(a+1,a+n+1);
    REP(i,1,n+1)
        {
        if(a[i] >= tmp)
            tmp += 1;
    }
    printf("%d\n",tmp);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 100;
map <ll , int> mp;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n ;
	cin >> n;
	vector<ll>  a(n);
	for(int i = 0 ; i < n;i ++)
		cin >> a[i] , mp[a[i] ] ++ ;
	sort(a.begin()  , a.end()  );
	for(int i = 1; i<=n+1; i ++)
	{
		int h = i;
		while ( mp[h] > 0)
			h++;
		//cout <<h << "ITS H " << endl;
		int f = lower_bound( a.begin() , a.end()  , h ) - a.begin();
		//cout << "ITS F " << f << endl;
		if ( f >= a.size()  )
		{
			return cout << h << endl,  0;
		}
		mp[a[f] ]--;
		mp[h] = 1;
		a.erase( a.begin() + f );
		i = h;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 100;
map <ll , int> mp;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n ;
	cin >> n;
	vector<ll>  a(n);
	for(int i = 0 ; i < n;i ++)
		cin >> a[i] , mp[a[i] ] ++ ;
	sort(a.begin()  , a.end()  );
	for(int i = 1; i<=1e5+100; i ++)
	{
		int h = i;
		while ( mp[h] > 0)
			h++;
		//cout <<h << "ITS H " << endl;
		int f = lower_bound( a.begin() , a.end()  , h ) - a.begin();
		//cout << "ITS F " << f << endl;
		if ( f >= a.size()  )
		{
			return cout << h << endl,  0;
		}
		mp[a[f] ]--;
		mp[h] = 1;
		a.erase( a.begin() + f );
		i = h;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 100;
map <ll , bool> mp;
int main()
{
	int n ;
	cin >> n;
	vector<ll>  a(n);
	for(int i = 0 ; i < n;i ++)
		cin >> a[i] , mp[a[i] ] = 1;
	sort(a.begin()  , a.end()  );
	for(int i = 1; i<=1e5+100; i ++)
	{
		int h = i;
		while ( mp[h] )
			h++;
	//	cout <<h << "ITS H " << endl;
		int f = lower_bound( a.begin() , a.end()  , h ) - a.begin();
	//	cout << "ITS F " << f << endl;
		if ( f >= a.size()  )
		{
			return cout << h << endl,  0;
		}
		mp[h] = 1;
		a.erase( a.begin() + f );
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 100;
map <ll , int> mp;
int main()
{
	int n ;
	cin >> n;
	vector<ll>  a(n);
	for(int i = 0 ; i < n;i ++)
		cin >> a[i] , mp[a[i] ] ++ ;
	sort(a.begin()  , a.end()  );
	for(int i = 1; i<=1e5+100; i ++)
	{
		int h = i;
		while ( mp[h] > 0)
			h++;
		//cout <<h << "ITS H " << endl;
		int f = lower_bound( a.begin() , a.end()  , h ) - a.begin();
		//cout << "ITS F " << f << endl;
		if ( f >= a.size()  )
		{
			return cout << h << endl,  0;
		}
		mp[a[f] ]--;
		mp[h] = 1;
		a.erase( a.begin() + f );
		i = h;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 1;
bool mp[N];
int main()
{
	int n , ans = 1;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0 ; i < n; i ++)
		cin >> a[i];
	sort(a.begin() , a.end() );
	for(int i = 0 ; i < n; i ++)
	{
		if ( a[i] < ans )
			continue;
		else
			ans ++;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 100;
map <ll , int> mp;
int main()
{
	int n ;
	cin >> n;
	vector<ll>  a(n);
	for(int i = 0 ; i < n;i ++)
		cin >> a[i] , mp[a[i] ] ++ ;
	sort(a.begin()  , a.end()  );
	for(int i = 1; i<=1e5+100; i ++)
	{
		int h = i;
		while ( mp[h] > 0)
			h++;
		//cout <<h << "ITS H " << endl;
		int f = lower_bound( a.begin() , a.end()  , h ) - a.begin();
		//cout << "ITS F " << f << endl;
		if ( f >= a.size()  )
		{
			return cout << h << endl,  0;
		}
		mp[a[f] ]--;
		mp[h] = 1;
		a.erase( a.begin() + f );
	}
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  int menorpos=1;
  int resp=0;
  int mexeu=0;
  for(int i=0;i<n;i++){
    if(v[i]==menorpos+1){
      menorpos=v[i];
    }
    else if(v[i]>menorpos and mexeu<n-2){
      menorpos++;
      mexeu++;
    }
  }
  resp=menorpos+1;
  cout<<resp<<endl;
  return 0;
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n+1,0);
  int maior=0;
  for(int i=0;i<n;i++) {
    int x;
    cin>>x;
    if(x<=n) v[x]++;
    else maior++;
  }
  if(maior==n) cout<<n<<endl;
  else{
    int sobrou=0;
    int deu=0;
    for(int i=1;i<=n;i++){
      sobrou+=v[i]-1;
      sobrou=min(sobrou,0);
    }
    cout<<n+1+sobrou+maior<<endl;
  }
  return 0;
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n+1,0);
  int maior=0;
  for(int i=0;i<n;i++) {
    int x;
    cin>>x;
    if(x<=n) v[x]++;
    else maior++;
  }
  if(maior==n or v[n]==n) cout<<n<<endl;
  else{
    int sobrou=0;
    int deu=0;
    for(int i=1;i<=n;i++){
      sobrou+=v[i]-1;
      sobrou=min(sobrou,0);
    }
    cout<<n+1+sobrou+maior<<endl;
  }
  return 0;
}


#include <cstring>
#include <iostream>
#include <bitset>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <utility>
#include <algorithm>
#include <iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v)                                        \
  for (int X = 0; X < v.size(); X++) cout << v[X] << " "; \
  cout << endl;
#define grid(v)                                                   \
  for (int X = 0; X < v.size(); X++) {                            \
    for (int Y = 0; Y < v[X].size(); Y++) cout << v[X][Y] << " "; \
    cout << endl;                                                 \
  }
#define endl "\n"
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;
const int MOD = 1e9 + 7;
int main()
{
  int n;
  cin >> n;
  vi v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int menorpos = 1;
  for (int i = 0; i < n; i++) {
    if (v[i] >= menorpos) {
      menorpos++;
    }
  }
  cout << menorpos << endl;
  return 0;
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  int menorpos=1;
  int resp=0;
  for(int i=0;i<n;i++){
    if(v[i]==menorpos){
      menorpos=v[i];
    }
    else if(v[i]>menorpos){
      menorpos++;
    }
  }
  resp=menorpos+1;
  cout<<resp<<endl;
  return 0;
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n+1,0);
  int maior=0;
  for(int i=0;i<n;i++) {
    int x;
    cin>>x;
    if(x<=n) v[x]++;
    else maior++;
  }
    int sobrou=0;
    int deu=0;
    for(int i=1;i<n;i++){
      sobrou+=v[i]-1;
      sobrou=min(sobrou,0);
    }
    sobrou+=v[n]-1;
    cout<<n+1+sobrou+maior<<endl;

  return 0;
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n+1,0);
  int maior=0;
  for(int i=0;i<n;i++) {
    int x;
    cin>>x;
    if(x<=n) v[x]++;
    else maior++;
  }
  if(maior==n) cout<<n<<endl;
  else{
    int sobrou=0;
    int deu=0;
    for(int i=1;i<n;i++){
      sobrou+=v[i]-1;
      sobrou=min(sobrou,0);
    }
    sobrou+=v[n]-1;
    cout<<n+1+sobrou+maior<<endl;
  }
  return 0;
}


#include<cstring>
#include<iostream>
#include<bitset>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
int main()
{
  int n;
  cin>>n;
  vi v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  int menorpos=1;
  int resp=0;
  bool ok=false;
  for(int i=0;i<n;i++){
    if(v[i]==menorpos){
      menorpos=v[i];
    }
    else if(v[i]>menorpos){
      menorpos++;
    }
    else {
      resp=menorpos;
      ok=true;
      break;
    }
  }
  if(!ok) resp=menorpos+1;
  cout<<resp<<endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define si set<int>
#define sll set<ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[100005];
int main(){
    FIO;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=a[1]-1;
    a[1]=1;
    rep(i,2,n){
        if(a[i]-a[i-1]>1){
            ans=max(ans,a[i]-1);
            a[i]=a[i-1]+1;
    }
    }
    cout<<max(ans,a[n]+1);
    /*cin>>n>>m;
    int d1=n/5,d2=n%5;
    int d3=m/5,d4=m%5;
    ll ans=0;
    rep(i,1,4){
        ll x1=d1;
        if(d2>=i) x1++;
        ll x2=d3;
        if(d4>=(5-i)) x2++;
        ans+=(x1*x2);
    }
    ans+=(d1*d3);
    cout<<ans;*/
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define si set<int>
#define sll set<ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[100005];
int main(){
    FIO;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=a[1]-1;
    a[1]=1;
    rep(i,2,n){
        if(a[i]-a[i-1]>1) a[i]=a[i-1]+1;
    }
    cout<<max(ans,a[n]+1);
    /*cin>>n>>m;
    int d1=n/5,d2=n%5;
    int d3=m/5,d4=m%5;
    ll ans=0;
    rep(i,1,4){
        ll x1=d1;
        if(d2>=i) x1++;
        ll x2=d3;
        if(d4>=(5-i)) x2++;
        ans+=(x1*x2);
    }
    ans+=(d1*d3);
    cout<<ans;*/
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define si set<int>
#define sll set<ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[100005];
int main(){
    FIO;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=a[1]-1;
    a[1]=1;
    rep(i,2,n){
        if(a[i]-a[i-1]>1){
            ans=max(ans,a[i]-1);
            a[i]=a[i-1]+1;
    }
    cout<<max(ans,a[n]+1);
    /*cin>>n>>m;
    int d1=n/5,d2=n%5;
    int d3=m/5,d4=m%5;
    ll ans=0;
    rep(i,1,4){
        ll x1=d1;
        if(d2>=i) x1++;
        ll x2=d3;
        if(d4>=(5-i)) x2++;
        ans+=(x1*x2);
    }
    ans+=(d1*d3);
    cout<<ans;*/
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define si set<int>
#define sll set<ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[100005];
int main(){
    FIO;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=(a[1]==1)?0:1;
    a[1]=1;
    rep(i,2,n){
        if(a[i]-a[i-1]>1){
            ans=max(ans,a[i-1]+1);
            a[i]=a[i-1]+1;
    }
    }
    cout<<max(ans,a[n]+1);
    /*cin>>n>>m;
    int d1=n/5,d2=n%5;
    int d3=m/5,d4=m%5;
    ll ans=0;
    rep(i,1,4){
        ll x1=d1;
        if(d2>=i) x1++;
        ll x2=d3;
        if(d4>=(5-i)) x2++;
        ans+=(x1*x2);
    }
    ans+=(d1*d3);
    cout<<ans;*/
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define si set<int>
#define sll set<ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[100005];
int main(){
    FIO;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    rep(i,2,n){
        if(a[i]-a[i-1]>1) a[i]=a[i-1]+1;
    }
    cout<<a[n]+1;
    /*cin>>n>>m;
    int d1=n/5,d2=n%5;
    int d3=m/5,d4=m%5;
    ll ans=0;
    rep(i,1,4){
        ll x1=d1;
        if(d2>=i) x1++;
        ll x2=d3;
        if(d4>=(5-i)) x2++;
        ans+=(x1*x2);
    }
    ans+=(d1*d3);
    cout<<ans;*/
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define si set<int>
#define sll set<ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int n,m;
int main(){
    FIO;
    cin>>n>>m;
    int d1=n/5,d2=n%5;
    int d3=m/5,d4=m%5;
    ll ans=0;
    rep(i,1,4){
        ll x1=d1;
        if(d2>=i) x1++;
        ll x2=d3;
        if(d4>=(5-i)) x2++;
        ans+=(x1*x2);
    }
    ans+=(d1*d3);
    cout<<ans;
}


/*                              King Of Phantoms                                */
#include <bits/stdc++.h>
int i, j;
bool f  = 0 ;
using namespace std;
int main() {
    int n , x ;
    scanf("%d",&n);
    int a[x];
    vector <int> v ;
    for (i = 0 ; i < n ; ++i )
        scanf("%d",&a[i]);
    sort( a , a+n );
    for (i = 0 ,j = 1; i < n ; ++i,++j) {
        if (a[i] != j) {
            v.push_back(j);
            f = 1 ;
        }
        while ( abs( a[i] - j ) > 1 ){
            ++j;
        }
        v.push_back(j);
    }
    sort( v.begin() , v.end() );
    if (f) {
        cout << v[v.size()-1] << endl;
        return 0;
    }
    cout << a[n-1] + 1 << endl;
}


/*                              King Of Phantoms                                */
#include <bits/stdc++.h>
int i , j , z = 0;
bool f  = 0 ;
using namespace std;
int main() {
    int n ;
    scanf("%d",&n);
    int a[n];
    for (i = 0 ; i < n ; ++i )
        scanf("%d",&a[i]);
    sort( a , a+n );
    for (i = 0 ,j = 1; i < n ; ++i) {
        if (a[i] >= j ) {
            ++j;
        }
    }
    cout << j << endl;

}


/*                              King Of Phantoms                                */
#include <bits/stdc++.h>
int i, j;
bool f  = 0 ;
using namespace std;
int main() {
    int n , x ;
    scanf("%d",&n);
    int a[x];
    vector <int> v ;
    for (i = 0 ; i < n ; ++i )
        scanf("%d",&a[i]);
    sort( a , a+n );
    for (i = 0 ,j = 1; i < n ; ++i,++j) {
        if (a[i] != j) {
            v.push_back(j);
            f = 1 ;
        }
        while ( abs( a[i] - j ) > 1 ){
            v.push_back(++j);
        }

    }
    sort( v.begin() , v.end() );
    if (f) {
        cout << v[v.size()-1] << endl;
        return 0;
    }
    cout << a[n-1] + 1 << endl;
}


/*                              King Of Phantoms                                */
#include <bits/stdc++.h>
int i, j;
bool f  = 0 ;
using namespace std;
int main() {
    int n , x ;
    scanf("%d",&n);
    int a[x];
    vector <int> v ;
    for (i = 0 ; i < n ; ++i )
        scanf("%d",&a[i]);
    sort( a , a+n );
    for (i = 0 ,j = 1; i < n ; ++i,++j) {
        if (a[i] != j) {
            while (j < ( a[i] - 1 )) {
                ++j;
            }
            v.push_back(j);
            j = a[i]  ;
            f = 1 ;
        }
    }
    sort( v.begin() , v.end() );
    if (f) {
        cout << v[v.size()-1] << endl;
        return 0;
    }
    cout << a[n-1] + 1 << endl;
}


/*                              King Of Phantoms                                */
#include <bits/stdc++.h>
int i, j;
bool f  = 0 ;
using namespace std;
int main() {
    int n , x ;
    scanf("%d",&n);
    int a[x];
    vector <int> v ;
    for (i = 0 ; i < n ; ++i )
        scanf("%d",&a[i]);
    sort( a , a+n );
    for (i = 0 ,j = 1; i < n ; ++i,++j) {
        if (a[i] != j) {
            v.push_back(j);
            j = a[i];
            f = 1 ;
        }
    }
    sort( v.begin() , v.end() );
    if (f) {
        cout << v[v.size()-1] << endl;
        return 0;
    }
    cout << a[n-1] + 1 << endl;
}


/*                              King Of Phantoms                                */
#include <bits/stdc++.h>
int i, j;
bool f  = 0 ;
using namespace std;
int main() {
    int n , x ;
    scanf("%d",&n);
    int a[x];
    vector <int> v ;
    for (i = 0 ; i < n ; ++i )
        scanf("%d",&a[i]);
    sort( a , a+n );
    for (i = 0 ,j = 1; i < n ; ++i,++j) {
        if (a[i] != j) {
            v.push_back(j);
            f = 1 ;
        }
    }
    sort( v.begin() , v.end() );
    if (f) {
        cout << v[v.size()-1] << endl;
        return 0;
    }
    cout << a[n-1] + 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll  INF = 1e18;
map<int,bool>Mop;
int main()
{
	ios::sync_with_stdio(0);
	int n; cin >> n;
	if(n == 1)
	{
		int t; cin >> t;
		if(t > 1)
		{
			cout << 1 << endl;
		}
		else cout << 2 << endl;
		return 0;
	}
	vector<int>arr;
	for(int i = 0;i < n;i++)
	{
		int t; cin >> t;
		arr.push_back(t);
	}
	sort(arr.begin(),arr.end());
	for(int i = 1;i < n;i++)
	{
		if(arr[i-1] != arr[i])arr[i] = arr[i-1]+1;
	}
	cout << arr[n-1]+1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll  INF = 1e18;
map<int,bool>Mop;
int main()
{
	ios::sync_with_stdio(0);
	int n; cin >> n;
	vector<int>arr;
	for(int i = 0;i < n;i++)
	{
		int t; cin >> t;
		arr.push_back(t);
	}
	sort(arr.begin(),arr.end());
	int Ans = 1;
	for(int i = 0;i < n;i++)
	{
		if(Ans< arr[i])
		{
			Ans++;
		}
	}
	cout << Ans<< endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll  INF = 1e18;
map<int,bool>Mop;
int main()
{
	ios::sync_with_stdio(0);
	int n; cin >> n;
	if(n == 1)
	{
		int t; cin >> t;
		if(t > 1)
		{
			cout << 1 << endl;
		}
		else cout << 2 << endl;
		return 0;
	}
	vector<int>arr;
	for(int i = 0;i < n;i++)
	{
		int t; cin >> t;
		arr.push_back(t);
	}
	sort(arr.begin(),arr.end());
	for(int i = 1;i < n;i++)
	{
		if(arr[i-1] != arr[i])arr[i] = arr[i-1]+1;
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll  INF = 1e18;
map<int,bool>Mop;
int main()
{
	ios::sync_with_stdio(0);
	int n; cin >> n ;
	vector<int>arr;
	for(int i = 0;i < n;i++)
	{
		int t; cin >> t;
		arr.push_back(t);
	}
	sort(arr.begin(),arr.end());
	for(int i = 1;i < n;i++)
	{
		if(arr[i-1] != arr[i])arr[i] = arr[i-1]+1;
	}
	cout << arr[n-1]+1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll  INF = 1e18;
map<int,bool>Mop;
int main()
{
	ios::sync_with_stdio(0);
	int n; cin >> n;
	vector<int>arr;
	for(int i = 0;i < n;i++)
	{
		int t; cin >> t;
		arr.push_back(t);
	}
	sort(arr.begin(),arr.end());
	int Ans = 1;
	for(int i = 0;i < n;i++)
	{
		if(Ans <= arr[i])
		{
			Ans++;
		}
	}
	cout << Ans<< endl;
}


#include <cstdio>
#include <map>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  for(int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    if(cnt.count(num)) {
      cnt[num] = cnt[num] + 1;
    } else {
      cnt[num] = 1;
    }
  }
  int prev = 0;
  int sum = 0;
  for(map<int, int>::iterator itr = cnt.begin(); itr != cnt.end(); itr++) {
    int s = itr->first;
    int v = itr->second;
    prev += v;
    prev = min(prev, s);
  }
  printf("%d\n", prev + 1);
  return 0;
}


#include <cstdio>
#include <map>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  for(int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    if(cnt.count(num)) {
      cnt[num] = cnt[num] + 1;
    } else {
      cnt[num] = 1;
    }
  }
  int prev = 0;
  for(map<int, int>::iterator itr = cnt.begin(); itr != cnt.end(); itr++) {
    int s = itr->first;
    int v = itr->second;
    if(v < s - prev) {
      prev += v;
      break;
    } else {
      prev = s;
    }
  }
  printf("%d\n", prev + 1);
  return 0;
}


#include <cstdio>
#include <map>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  for(int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    cnt[num]++;
  }
  int prev = 0;
  for(map<int, int>::iterator itr = cnt.begin(); itr != cnt.end(); itr++) {
    int s = itr->first;
    int v = itr->second;
    if(v < s - prev) {
      prev += v;
      break;
    }
    prev = s;
  }
  printf("%d\n", prev + 1);
  return 0;
}


#include <cstdio>
#include <map>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  int cap = 0;
  for(int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    cap = max(cap, num);
    if(cnt.count(num)) {
      cnt[num] = cnt[num] + 1;
    } else {
      cnt[num] = 1;
    }
  }
  int prev = 0;
  int sum = 0;
  for(map<int, int>::iterator itr = cnt.begin(); itr != cnt.end(); itr++) {
    int s = itr->first;
    int v = itr->second;
    if(v < s - prev) {
      prev += (n - sum);
      prev = min(prev, cap);
      break;
    } else {
      prev = s;
      sum += v;
    }
  }
  printf("%d\n", prev + 1);
  return 0;
}


#include <cstdio>
#include <map>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  for(int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    if(cnt.count(num)) {
      cnt[num] = cnt[num] + 1;
    } else {
      cnt[num] = 1;
    }
  }
  int prev = 0;
  int sum = 0;
  for(map<int, int>::iterator itr = cnt.begin(); itr != cnt.end(); itr++) {
    int s = itr->first;
    int v = itr->second;
    if(v < s - prev) {
      prev += (n - sum);
      break;
    } else {
      prev = s;
      sum += v;
    }
  }
  printf("%d\n", prev + 1);
  return 0;
}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(),c.end()

using namespace std;
int main()
{
    long long int n;
    cin>>n;
    if(n==1){
        cout<<2;return 0;
    }
    long long int t[n];
    for(long long int i=0;i<n;i++){
        cin>>t[i];
    }sort(t,t+n);
    bool check=false;
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]==t[i]){
            check=true;
            break;
        }
    }
    if(t[n-1]==n){
        cout<<n+1;
        return 0;
    }else if(t[n-1]>n && check){
        cout<<n;
    }else{
        cout<<n+1;
    }

}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(),c.end()

using namespace std;
int main()
{
    long long int n;
    cin>>n;
    if(n==1){
        cout<<2;return 0;
    }
    long long int t[n];
    for(long long int i=0;i<n;i++){
        cin>>t[i];
    }sort(t,t+n);
    bool check=false;
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]==t[i]){
            check=true;
            break;
        }
    }
    if(t[n-1]==n){
        cout<<n+1;
        return 0;
    }else if(t[n-1]>n && check){
        cout<<n;
    }else{
        if(check){
            cout<<n;
        }else{
            cout<<n+1;
        }
    }

}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(),c.end()

using namespace std;
int main()
{
    long long int n;
    cin>>n;
    if(n==1){
        cout<<2;return 0;
    }
    long long int t[n];
    for(long long int i=0;i<n;i++){
        cin>>t[i];
    }sort(t,t+n);
    if(t[n-1]==n){
        cout<<n+1;
        return 0;
    }else{
        cout<<n;
    }

}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(),c.end()

using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int t[n];
    for(long long int i=0;i<n;i++){
        cin>>t[i];
    }sort(t,t+n);
    here:
    for(long long int j=0;j<n-1;j++){
        if(t[j+1]>t[j]+1){
            t[j+1]--;
        }
    }
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]>t[i]+1){
            goto here;
        }
    }
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]>t[i]+1){
            cout<<t[i]+1;return 0;
        }
    }
    cout<<t[n-1]+1;
}


#include <stdio.h>
#include <algorithm>
using namespace std;

int n;
int arr[100005];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &arr[i]);
  sort(arr,arr+n);

  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] >= ans) {
      ans++;
    }
  }
  printf("%d\n", ans);
}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(),c.end()

using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int t[n];
    for(long long int i=0;i<n;i++){
        cin>>t[i];
    }sort(t,t+n);
    here:
    for(long long int j=0;j<n-1;j++){
        if(t[j+1]>t[j]+1){
            t[j+1]--;
        }
    }
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]>t[i]+1){
            goto here;
        }
    }
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]>t[i]+1){
            cout<<t[i]+1;return 0;
        }
    }
    if(n==1){

        cout<<2;return 0;
    }
    cout<<t[n-1]+1;
}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(),c.end()

using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int t[n];
    for(long long int i=0;i<n;i++){
        cin>>t[i];
    }sort(t,t+n);
    here:
    for(long long int j=0;j<n-1;j++){
        if(t[j+1]>t[j]+1){
            t[j+1]--;
        }
    }
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]>t[i]+1){
            goto here;
        }
    }
    for(long long int i=0;i<n-1;i++){
        if(t[i+1]>t[i]+1){
            cout<<t[i]+1;return 0;
        }
    }
    if(n==1){
    for(long long int i=2;i<t[n-1];i++){
        if(i<t[n-1]){
            cout<<i;
            return 0;
        }
    }}
    cout<<t[n-1]+1;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int b=1;
    int n;cin>>n;
    int a[900000];
    for(int c=0;c<n;c++){
    cin>>a[c];
    if(a[c]>=b)b++;}
    cout<<b;
    return 0;
}


#include<iostream>
#include<algorithm>
suing namespace std;
int main(){

    int c=1;
    int n;cin>>n;
    int a[900000];
    for(int c=0;c<n;c++){
    cin>>a[c];
    if(a[c]>=c)c++;}
    cout<<c;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int b=1;
    int n;cin>>n;
    int a[900000];
    for(int c=0;c<n;c++)
    cin>>a[c];
    sort(a,a+n);
    for(int c=0;c<n;c++){
    if(a[c]>=b)b++;}
    cout<<b;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int c=1;
    int n;cin>>n;
    int a[900000];
    for(int c=0;c<n;c++){
    cin>>a[c];
    if(a[c]>=c)c++;}
    cout<<c;
    return 0;
}


#include<iostream>
#include<algorithm>
suing namespace std;
int main(){

    int c=1;
    int n;cin>>n;
    int a[900000];
    for(int c=0;c<n;c++){
    cin>>a[c];
    if(a[c]>=c)c++;}
    cout<<C;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, min;
bool c;
int main() {
cin>>n;
int a[n+1];
int b[n+1];
  for (i=1; i<=n; i++){
   cin>>a[i];
   b[i]=1;
  }

  sort(a+1, a+n+1);
  if (a[1]>1)
    a[1]=1;

  for (i=1; i<n; i++){
    c=false;
    if (a[i+1]-a[i]>1){
      b[i+1]=a[i]+1;
      c=true;
    }
  }
if (n==1)
  cout<<2;
else
if (c==true)
  cout<<b[n]+1;
else
  cout<<a[n]+1;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, x;
int main() {
cin>>n;
int a[n+1];

for (i=1; i<=n; i++)
  cin>>a[i];

x=1;

sort(a+1, a+n+1);

for(i=1; i<=n; i++){
  if (a[i]>=x)
    x++;
}
cout<<x;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, min;
bool c;
int main() {
cin>>n;
int a[n+1];
int b[n+1];
  for (i=1; i<=n; i++){
   cin>>a[i];
   b[i]=1;
  }

  sort(a+1, a+n+1);

  for (i=1; i<n; i++){
    if (a[i+1]-a[i]>1){
      b[i+1]=a[i]+1;
      c=true;
    }
  }
if (n==1)
  cout<<2;
else
if (c==true)
  cout<<b[n]+1;
else
  cout<<a[n]+1;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, min;
bool c;
int main() {
cin>>n;
int a[n+1];
int b[n+1];
  for (i=1; i<=n; i++){
   cin>>a[i];
   b[i]=1;
  }

  sort(a+1, a+n+1);
  if (a[1]>1)
    a[1]=1;

  for (i=1; i<n; i++){
    if (a[i+1]-a[i]>1){
      b[i+1]=a[i]+1;
      c=true;
    }
  }
if (n==1)
  cout<<2;
else
if (c==true)
  cout<<b[n]+1;
else
  cout<<a[n]+1;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, min;
bool c;
int main() {
cin>>n;
int a[n+1];
int b[n+1];
  for (i=1; i<=n; i++){
   cin>>a[i];
   b[i]=1;
  }

  sort(a+1, a+n+1);
  if (a[1]>1)
    a[1]=1;

  for (i=1; i<n; i++){
    c=false;
    if ((a[i+1]-a[i]>1) || (a[i+1]-a[i]==0)){
      b[i+1]=a[i]+1;
      c=true;
    }
  }
if (n==1)
  cout<<2;
else
if (c==true)
  cout<<b[n]+1;
else
  cout<<a[n]+1;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, min;
bool c;
int main() {
cin>>n;
int a[n+1];
int b[n+1];
  for (i=1; i<=n; i++){
   cin>>a[i];
   b[i]=1;
  }

  sort(a+1, a+n+1);

  for (i=1; i<n; i++){
    if (a[i+1]-a[i]>1){
      b[i+1]=a[i]+1;
      c=true;
    }
  }

if (c==true)
  cout<<b[n]+1;
else
  cout<<a[n]+1;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, min;
bool c;
int main() {
cin>>n;
int a[n+1];
int b[n+1];
  for (i=1; i<=n; i++){
   cin>>a[i];
   b[i]=1;
  }

  sort(a+1, a+n+1);
  if (a[1]>1)
    a[i]=1;

  for (i=1; i<n; i++){
    if (a[i+1]-a[i]>1){
      b[i+1]=a[i]+1;
      c=true;
    }
  }
if (n==1)
  cout<<2;
else
if (c==true)
  cout<<b[n]+1;
else
  cout<<a[n]+1;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, i, x;
int main() {
cin>>n;
int a[n+1];

for (i=1; i<=n; i++)
  cin>>a[i];

x=1;

for(i=1; i<=n; i++){
  if (a[i]>x)
    x++;
}
cout<<x+1;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	//pyiiyg
	//oyidh
	ll n;
	scanf("%lld",&n);
	ll a[n];
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>ans)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	scanf("%lld",&n);
	ll a[n];
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=i+1)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	scanf("%lld",&n);
	ll a[n];
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>ans)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int ans=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=i+1)
		{
			ans++;
		}
	}
	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	scanf("%lld",&n);
	ll a[n];
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=ans)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	scanf("%lld",&n);
	ll a[n];
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>ans)
		{
			ans++;
		}
	}
	printf("%lld\n",ans+1);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	scanf("%lld",&n);
	ll a[n];
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	if(n==1)
	{
		printf("%lld\n",a[0]+1);
		return 0;
	}
	sort(a,a+n);
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=i+1)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
}


//Codeforces Problem Set 1307A

#include<stdio.h>
#include<stdlib.h>

int maxbales(int, int);
int min(int, int);

int main()
{
	int test, hayPiles, days;
	(void) scanf("%d", &test);
	while (0 < test--)
	{
		(void) scanf("%d %d", &hayPiles, &days);
		(void) printf("%d\n", maxbales(hayPiles, days));
	}
	return 0;
}

int maxbales(int hP, int days)
{
	int stack0 = 0;
	int addition, stack;
	for (int i = 0; i < hP; i += 1)
	{
		(void)scanf("%d", &stack);
		if (days > 0)
		{
			if (i == 0)
			{
				addition = stack;
			}
			else
			{
				if (days < i)
				{
					//break; Then the remainder of the characters in the line will distort the input.
					addition = 0;
					days = 0;
				}
				else
				{
					addition = min(days/i, stack);
					days -= addition*i;
				}
			}
		}
		stack0 += addition;
	}
	return stack0;
}

int min(int num1, int num2)
{
	if (num1 < num2)
		return num1;
	return num2;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int a[105]={0};
int main()
{
    int t=0;
    int n=0,d=0;
    int i=0,j=0;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&d);
        for(i=0;i<=n-1;i++)
        {
            scanf("%d",&a[i]);
        }
        if(n==1)
        {
            printf("%d\n",a[0]);
            continue;
        }
        for(i=1;d>0;)
        {
            if(a[i]!=0)
            {
                a[i]--;
                a[0]++;
                d=d-i;
            }
            else i++;
        }
        if(d==0)
        {
            printf("%d\n",a[0]);
        }
        else printf("%d\n",a[0]-1);
    }
    return 0;
}


#include<stdio.h>
int main(){
    long long int t,q,n,d,h,i;
    scanf("%lld",&t);
    for(q=0;q<t;q++){
        long long int pile1=0,s=0,f=0;
        scanf("%lld%lld",&n,&d);
        for(i=0;i<n;i++){
            scanf("%lld",&h);
            if(pile1==0){s=h;pile1++;continue;}
            if(d/i<=h&&f==0){
                s=s+d/i;
                d=0;
                f=1;
            }
            else if (f==0){
                s=s+h;
                d=d-h*i;
            }
        }
        printf("%lld\n",s);

    }
    return 0;
}


#include<stdio.h>

int main()
{int t;
scanf("%d",&t);
while(t)
   {int n,d,i,j,count=0;
    scanf("%d %d",&n,&d);
    int a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    if(n>1)
    {
    for(j=1;j<n;j++)
    while(a[j]>0 && d>0)
    {a[j]--;
    d=d-j;
    count++;}
    printf("%d\n",a[0]+count);
    }
    else
   {printf("%d\n",a[0]);
    t--;}}
    return 0;
}


#include<stdio.h>

int main()
{int t;
scanf("%d",&t);
while(t)
   {int n,d,i,j,count=0;
    scanf("%d %d",&n,&d);
    int a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    if(n>1)
    {
    for(j=1;j<n;j++)
    while(a[j]>0 && d>0)
    {a[j]--;
    d=d-j;
    count++;}
    printf("%d\n",a[0]+count);
    }
    else
   printf("%d\n",a[0]);
    t--;}
    return 0;
}


#include<stdio.h>

int main()
{int t;
scanf("%d",&t);
while(t)
   {int n,d,i,j,count=0,r;
    scanf("%d %d",&n,&d);
    int a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    if(n>1)
    {
    for(j=1;j<n;j++)
   { r=d/j;
    while(a[j]>0 && d>0 && r>0)
    {a[j]--;
    d=d-j;
    count++;
    r--;}}
    printf("%d\n",a[0]+count);}
    else
    printf("%d\n",a[0]);
    t--;}
    return 0;
}


#include<stdio.h>
int main(){
	int t,check,n,res,d,i,j,arr[100];
     scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d %d",&n,&d);
		for(j=0;j<n;j++)scanf("%d",&arr[j]);
		res=arr[0];
		check=0;
	    for(j=1;j<n;j++){
	    	if(arr[j]>0){
	    		while((arr[j]>0)&& (d>j) ){
	    			arr[j]-=1;
	    			d-=j;
	    			res+=1;
				}

			}
			if(d<j)break;

		}
		printf("%d\n",res);

	}

	return 0;
}


#include<stdio.h>
int main(){
	int t,check,n,res,d,i,j,arr[100];
     scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d %d",&n,&d);
		for(j=0;j<n;j++)scanf("%d",&arr[j]);
		res=arr[0];
		check=0;
	    for(j=1;j<n;j++){
	    	if(arr[j]>0){
	    		while((arr[j]>0)&& (d>=j) ){
	    			arr[j]-=1;
	    			d-=j;
	    			res+=1;
				}

			}
			if(d<j)break;

		}
		printf("%d\n",res);

	}

	return 0;
}