#include <bits/stdc++.h>
#pragma target("avx")
using namespace std;
constexpr long long INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr long long LINF = 1e18;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
long long n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
long long dp[90][1001];
int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long(i) = 0; (i) < (int)(n); (i)++) cin >> a[i];
  for (long long(i) = 0; (i) < (int)(85); (i)++)
    for (long long(j) = 0; (j) < (int)(1000); (j)++) dp[i][j] = -LINF;
  dp[0][0] = 1000;
  for (long long i = (1); i < (n + 1); i++) {
    for (long long(j) = 0; (j) < (int)(1000); (j)++) {
      for (long long(k) = 0; (k) < (int)(1000); (k)++) {
        if (k == j) {
          dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        } else if (k < j) {
          long long mai = j - k, money = mai * a[i - 1];
          if (dp[i - 1][k] - money >= 0) {
            dp[i][j] = max(dp[i][j], dp[i - 1][k] - money);
          }
        } else {
          long long mai = k - j, money = mai * a[i - 1];
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + money);
        }
      }
    }
  }
  for (long long(i) = 0; (i) < (int)(1000); (i)++) ans = max(ans, dp[n][i]);
  cout << (ans) << endl;
  return 0;
}
