Accepted
代码
#include<bits/stdc++.h>
const long long maxn=100001;
inline const void read(long long &a)
{
a=0;
char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
inline const void write(long long a)
{
if(a>9)write(a/10);
putchar(a%10+'0');
}
long long n,a[maxn],sum=0;
int main()
{
read(n);
for(long long i=1;i<=n;i++)read(a[i]);
std::sort(a+1,a+1+n);
for(long long i=1;i<=n;i++)
{
if(a[i]<=sum+1)sum+=a[i];
else break;
}
write(sum+1);
return 0;
}