#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e16;
long long dp[200010];
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long now = 1000;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 200010; j++) {
      dp[j] = -INF;
    }
    dp[0] = 0;
    long long to = now;
    for (long long j = 0; j <= now; j++) {
      dp[j + a[i]] = max(dp[j + a[i]], dp[j] + a[i + 1]);
    }
    for (long long j = 0; j <= now; j++) {
      to = max(to, dp[j] + now - j);
    }
    now = to;
  }
  cout << now << endl;
  return 0;
}
