Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
401 B
2
Indexable
Never
// y.ha
#include <bits/stdc++.h>
#define cook '\n'
using namespace std;
int n,a[1009] ;
int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(nullptr) ;
    cin >> n;
    for ( int i = 1; i <= n; i++ ) cin >> a[i] ;
    sort(a+1,a+1+n);
    int need = 1;
    for ( int i = 1; i <= n; i++ )
        if ( a[i] <= need ) need+= a[i] ;
            else break ;
    cout << need;
}
Leave a Comment