#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  vector<long long int> dp(100000, -INF);
  dp[0] = 1000;
  for (int i = 0; i < (N); ++i) {
    for (int j = 1; j < 100000; ++j) {
      if (dp[j - 1] - A[i] < 0) continue;
      dp[j] = max(dp[j], dp[j - 1] - A[i]);
    }
    for (int j = (100000 - 1) - 1; j >= 0; --j) {
      if (dp[j + 1] + A[i] < 0) continue;
      dp[j] = max(dp[j], dp[j + 1] + A[i]);
    }
  }
  cout << dp[0] << endl;
  return 0;
}
