#include using namespace std; typedef long long ll; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) const int MOD = 1000000007; vector P,M; unsigned int up, um; inline void bits(unsigned int &p, int n){ p |= (1<> N; REP(i,N) cin >> D[i]; int pn = 0, mn = 0; REP(i,N){ if(D[i] < 0){ M.push_back(-D[i]); } else { P.push_back(D[i]); } } sort(M.begin(), M.end(), greater()); sort(P.begin(), P.end(), greater()); int mv = 100, v = 100, cnt = 1000; while(cnt--){ bool f = false; REP(i,M.size()){ if(biti(um,i)) continue; if(v <= M[i]) continue; bits(um, i); v -= M[i], mv += 100; f = true; break; } if(f) continue; int lasti = -1; REP(i,P.size()){ if(biti(up,i)) continue; lasti = i; if(mv-v < P[i]) continue; bits(up, i); v += P[i]; f = true; break; } if(f) continue; if(lasti >= 0){ bits(up, lasti); v += P[lasti]; if(v > mv) v = mv; } } if(um != (1<