#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
ll ans;
vector<ll> aa(100);
void calc(ll day, ll yen, ll kabu) {
  if (day > n) {
    ans = max(ans, yen);
    return;
  }
  ll y = yen;
  ll k = kabu;
  while (y >= aa[day]) {
    y -= aa[day];
    k++;
    calc(day + 1, y, k);
  }
  y = yen;
  k = kabu;
  while (k > 0) {
    y += aa[day];
    k--;
    calc(day + 1, y, k);
  }
  calc(day + 1, yen, kabu);
}
int main() {
  ll a, b, c, h, i, j, k, l, m, x, y;
  ans = 1000;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> aa[i];
  calc(1, 1000, 0);
  cout << ans << endl;
  return 0;
}
