#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;
ll dp[99][1000];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll n, k;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (int)n; ++i) cin >> a[i];
  vector<vector<ll>> dp(99, vector<ll>(10000, -INFL));
  ll ans = 0;
  queue<tuple<ll, ll, ll>> q;
  q.emplace(0, 0, 1000);
  dp[0][0] = 1000;
  while (q.size()) {
    ll i, j, c;
    tie(i, j, c) = q.front();
    q.pop();
    if (dp[i][j] > c) continue;
    if (i == n) {
      ans = max(ans, c);
      continue;
    }
    for (int k = 0; k < (int)j + 1; ++k) {
      if (dp[i + 1][j - k] < dp[i][j] + a[i] * k) {
        dp[i + 1][j - k] = dp[i][j] + a[i] * k;
        q.emplace(i + 1, j - k, dp[i + 1][j - k]);
      }
    }
    ll k = 0;
    while (a[i] * k <= c) {
      if (dp[i + 1][j + k] < dp[i][j] - a[i] * k) {
        dp[i + 1][j + k] = dp[i][j] - a[i] * k;
        q.emplace(i + 1, j + k, dp[i + 1][j + k]);
      }
      ++k;
    }
  }
  cout << ans << endl;
  return 0;
}
