#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<vector<int> > dp(n, vector<int>(1000, -1));
  dp[0][0] = 1000;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < 1000; ++j) {
      if (dp[i][j] == -1) continue;
      for (int k = 0; k <= j; ++k)
        dp[i + 1][j - k] = max(dp[i + 1][j - k], dp[i][j] + k * a[i]);
      for (int k = 0; k * a[i] <= dp[i][j]; ++k)
        if (j + k < 1000)
          dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] - k * a[i]);
    }
  }
  int odp = 0;
  for (int i = 0; i < 1000; ++i)
    if (dp[n - 1][i] != -1) odp = max(odp, dp[n - 1][i] + i * a[n - 1]);
  cout << odp;
  return 0;
}
