#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long int dp[n + 1][5001];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < 5001; j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 1000;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 5001; j++) {
      if (dp[i - 1][j] == -1) continue;
      long long int cost = dp[i - 1][j];
      dp[i][j] = max(dp[i][j], cost);
      int num = j + 1;
      while (cost - a[i] >= 0) {
        cost = cost - a[i];
        dp[i][num] = max(dp[i][num], cost);
        num++;
      }
      cost = dp[i - 1][j];
      num = j - 1;
      while (num >= 0) {
        cost += a[i];
        dp[i][num] = max(dp[i][num], cost);
        num--;
      }
    }
  }
  cout << dp[n][0];
  return 0;
}
