#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 18000;
const int INF = 1e9;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n + 1, vector<int>(MAX + 3000, -INF));
  dp[0][1000] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= MAX; j++) {
      if (dp[i][j] < 0) continue;
      int p = j;
      int cnt = 0;
      while (p >= 0) {
        dp[i + 1][p] = max(dp[i + 1][p], dp[i][j] + cnt);
        cnt++;
        p -= a[i];
      }
      p = j;
      cnt = 0;
      while (cnt <= dp[i][j] && p <= MAX) {
        dp[i + 1][p] = max(dp[i + 1][p], dp[i][j] - cnt);
        p += a[i];
        cnt++;
      }
    }
  }
  int m = dp[n].size();
  for (int i = m - 1; i >= 0; i--) {
    if (dp[n][i] >= 0) {
      cout << i << endl;
      return 0;
    }
  }
}
