#include <bits/stdc++.h>
using namespace std;
const int N = 81;
const int M = 8000;
int n;
int a[N];
bool dp[N][500][M];
int ans;
void solve(int id, int stoke, int cur) {
  ans = max(ans, cur);
  if (id >= n) return;
  if (dp[id][stoke][cur]) return;
  dp[id][stoke][cur] = true;
  solve(id + 1, stoke, cur);
  if (cur >= a[id]) solve(id, stoke + 1, cur - a[id]);
  if (stoke > 0) solve(id, stoke - 1, cur + a[id]);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(dp, false, sizeof dp);
  ans = 1000;
  solve(0, 0, 1000);
  cout << ans << "\n";
}
