#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (long long i = 0; i < n; i++) cin >> arr[i];
  vector<vector<long long> > dp(n + 1, vector<long long>((long long)40000, -1));
  long long moneytmp = 1000;
  dp[0][0] = 1000;
  for (long long k = 1; moneytmp >= 0; k++) {
    moneytmp -= arr[0];
    if (moneytmp < 0) break;
    dp[0][k] = moneytmp;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < (long long)40000; j++) {
      long long money1 = dp[i][j];
      long long money2 = dp[i][j];
      if (money1 == -1) continue;
      dp[i + 1][j] = max((long long)dp[i + 1][j], (long long)dp[i][j]);
      for (long long k = 1; k <= j; k++) {
        money1 += arr[i];
        dp[i + 1][j - k] = max(dp[i + 1][j - k], money1);
      }
      for (long long k = 1; money2 >= 0; k++) {
        money2 -= arr[i];
        if (money2 < 0) break;
        dp[i + 1][j + k] = max(dp[i + 1][j + k], money2);
      }
    }
  }
  long long ans = dp[n][0];
  cout << ans << endl;
}
