#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 82;
const int S_MAX = 1002;
int n;
long long a[N_MAX];
long long dp[N_MAX][S_MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int j = 0; j <= 1000; j++) dp[0][j] = LLONG_MIN;
  dp[0][0] = 1000;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 1000; j++) {
      dp[i][j] = LLONG_MIN;
      for (int k = 0; k <= j; k++)
        if (dp[i - 1][j - k] >= a[i] * k)
          dp[i][j] = max(dp[i][j], dp[i - 1][j - k] - a[i] * k);
      for (int k = 0; k + j <= 1000; k++)
        if (dp[i - 1][j + k] > LLONG_MIN)
          dp[i][j] = max(dp[i][j], dp[i - 1][j + k] + a[i] * k);
    }
  cout << dp[n][0] << "\n";
  return 0;
}
