#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<vector<long long> > dp(100, vector<long long>(3000, -1e18));
  dp[0][0] = 1000;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3000; ++j) {
      for (int k = 0; j + k < 3000; ++k) {
        if (0 <= j - k && 0 <= dp[i][j]) {
          dp[i + 1][j - k] = max(dp[i + 1][j - k], dp[i][j] + k * a[i]);
        }
        if (0 <= dp[i][j] - k * a[i] && 0 <= dp[i][j]) {
          dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] - k * a[i]);
        }
      }
    }
  }
  long long ans = -1e18;
  for (int i = 0; i < 3000; ++i) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}
