#include <bits/stdc++.h>
using namespace std;
int dp[16000 + 1][200 + 1][80 + 1];
int deal_with(int money, int stocks, int day, int n, int arr[]) {
  if (day > n) return money;
  if (dp[money][stocks][day] != -1) return dp[money][stocks][day];
  for (int i = 0; i <= stocks; i++) {
    dp[money][stocks][day] =
        max(dp[money][stocks][day],
            deal_with(money + arr[day] * i, stocks - i, day + 1, n, arr));
  }
  int buy = 0;
  while ((buy + 1) * arr[day] <= money) {
    buy++;
    dp[money][stocks][day] =
        max(dp[money][stocks][day],
            deal_with(money - (arr[day] * buy), stocks + buy, day + 1, n, arr));
  }
  return dp[money][stocks][day];
}
void process() {
  for (int i = 0; i <= 16000; i++)
    for (int j = 0; j <= 200; j++)
      for (int k = 0; k <= 80; k++) dp[i][j][k] = -1;
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  cout << deal_with(1000, 0, 1, n, arr) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) process();
  cerr << "\n" << (float)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
  return 0;
}
