#include <bits/stdc++.h>
using namespace std;
constexpr auto mod = 1000000007;
const long long int INF = 100000000;
int n;
int ans = 0;
int dp[100][200] = {0};
void dfs(int v, int k, int c, vector<int>& a) {
  ans = max(ans, c + (k * a[v]));
  if (v == n - 1) return;
  for (int i = (1); i < (k + 1); i++) {
    if (dp[v + 1][k - i] >= c + a[v] * i) return;
    dp[v + 1][k - i] = c + a[v] * i;
    dfs(v + 1, k - i, c + a[v] * i, a);
  }
  for (int i = (1); i < (1 + (c / a[v])); i++) {
    if (dp[v + 1][k + i] >= c - a[v] * i) return;
    dp[v + 1][k + i] = c - a[v] * i;
    dfs(v + 1, k + i, c - a[v] * i, a);
  }
}
int main() {
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (n); i++) cin >> a[i];
  dp[0][0] = 1000;
  dfs(0, 0, 1000, a);
  cout << ans << endl;
  return 0;
}
