#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 2e9;
constexpr int M = 80010;
constexpr int A = 810;
int dp[M][A];
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  dp[1000][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < M; j++) {
      for (int k = A - 1; k >= 0; k--) {
        if (j + a[i] < M && k - 1 >= 0) dp[j + a[i]][k - 1] |= dp[j][k];
      }
    }
    for (int j = M - 1; j >= 0; j--) {
      for (int k = 0; k < A; k++) {
        if (j - a[i] >= 0 && k + 1 < A) dp[j - a[i]][k + 1] |= dp[j][k];
      }
    }
  }
  int res = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < A; j++)
      if (dp[i][j]) res = max(res, i);
  }
  cout << res << endl;
  return 0;
}
