#include <bits/stdc++.h>
using namespace std;
int n, ar[100];
int dp[50000][3000];
int findR(int ind, int stock, int w) {
  if (ind == n - 1)
    return (w + (stock * ar[ind]));
  else if (dp[w][stock] != -1)
    return dp[w][stock];
  int r1 = findR(ind + 1, stock, w);
  int r2 = findR(ind + 1, 0, w + (stock * ar[ind]));
  int r3 = findR(ind + 1, stock + (w / ar[ind]), w % ar[ind]);
  return dp[w][stock] = max(r1, max(r2, r3));
}
void solve() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ar[i];
  cout << findR(0, 0, 1000) << endl;
  return;
}
int main() {
  int tc = 1;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
