#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define mt make_tuple #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pii; const int INF = 1 << 29; const double EPS = 1e-9; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int N; vector D; int dp[1 << 20]; int main() { cin >> N; D.resize(N); for (int i = 0; i < N; i++) { cin >> D[i]; } dp[0] = 100; for (int mask = 0; mask < 1 << N; mask++) { if (dp[mask]) { int h = dp[mask]; int h_max = 100; for (int i = 0; i < N; i++) { if (mask >> i & 1) { if (D[i] < 0) { h_max += 100; } } } for (int i = 0; i < N; i++) { if ((mask >> i) & 1) continue; if (D[i] > 0) { dp[mask | (1 << i)] = max(dp[mask | (1 << i)], min(h_max, h + D[i])); } else { if (h + D[i] > 0) { dp[mask | (1 << i)] = max(dp[mask | (1 << i)], h + D[i]); } } } } } cout << dp[(1 << N) - 1] << endl; return 0; }