#include <bits/stdc++.h>
using namespace std;
vector<int> ar;
int n;
int dp[81][5000][301];
int rec(int idx, int cash, int st) {
  if (idx >= n || st < 0 || cash < 0) return max(0, cash);
  if (dp[idx][cash][st] != -1) return dp[idx][cash][st];
  int res = 0;
  for (int i = 0; i <= st; ++i)
    for (int j = 0; j <= cash; j += ar[idx]) {
      int x = (res, rec(idx + 1, cash - j + i * ar[idx], st - i + j / ar[idx]));
      if (x > res) res = x;
    }
  return dp[idx][cash][st] = res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, -1, sizeof dp);
  cin >> n;
  ar.resize(n);
  for (int i = 0; i < n; ++i) cin >> ar[i];
  cout << rec(0, 1000, 0);
  return 0;
}
