#include <bits/stdc++.h>
using namespace std;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
using long long = long long;
using hll = __int128;
using pii = pair<long long, long long>;
using ld = long double;
using pll = pair<long long, long long>;
template <typename T>
void do_uniq(vector<T> vec) {
  sort((vec).begin(), (vec).end());
  vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());
}
template <typename T>
void freadT(T &x) {
  x = 0;
  char ch = getchar_unlocked();
  long long sign = 1;
  while (!isdigit(ch)) {
    if (ch == '-') sign *= -1;
    ch = getchar_unlocked();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar_unlocked();
  }
  x *= sign;
}
long long ml(long long a, long long b) { return (a * 1ll * b); }
long long add(long long a, long long b) { return (a * 1ll + b); }
clock_t timestamp_start = clock();
void time_calc() {
  cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}
const int MAXN = 162;
const int MAXSUM = 81 * 220;
bool dp[MAXSUM][81][MAXN];
void solve() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int curr;
    cin >> curr;
    v.push_back(curr);
  }
  dp[1000][0][0] = true;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < MAXSUM; ++j) {
      for (int t = 0; t < MAXN; ++t) {
        if (!dp[j][i][t]) continue;
        int curr = j - v[i];
        int cnt = 1;
        while (curr >= 0 && t + cnt <= MAXN) {
          dp[curr][i + 1][t + cnt] |= dp[j][i][t];
          cnt++;
          curr -= v[i];
        }
        curr = j + v[i];
        cnt = 1;
        while (curr < MAXSUM && t >= cnt) {
          dp[curr][i + 1][t - cnt] |= dp[j][i][t];
          curr += v[i];
          ++cnt;
        }
        dp[j][i + 1][t] |= dp[j][i][t];
      }
    }
  }
  int maxx = 0;
  for (int i = 0; i < MAXN; ++i) {
    for (int j = 0; j < MAXSUM; ++j) {
      if (dp[j][n][i]) maxx = max(maxx, j);
    }
  }
  cout << maxx;
}
void multisolve() {
  int t;
  cin >> t;
  int i = 1;
  while (t--) {
    cout << "Case #" << (i++) << ":\n";
    solve();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(20);
  solve();
}
