#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000007 #define INF 1000000000 char dp[1001][100001][2]; int main(){ int n; cin>>n; vector v; rep(i,0,n){ int a; cin>>a; v.pb(a); } dp[0][0][0]=1; rep(i,1,v.sz+1){ rep(j,0,100001){ // 取る dp[i][j+v[i-1]][1]=max(dp[i][j+v[i-1]][1],dp[i-1][j][0]); // 取らない dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][0]); dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][1]); } } int mx = 0; rep(i,0,100001){ if(dp[v.sz][i][0]==1||dp[v.sz][i][1]==1){ mx = max(mx,i); } } cout << mx << endl; return 0; }