#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, Mod = 1e9 + 7;
long long dp[105][10005][20];
vector<long long> v;
long long n;
long long res(long long id, long long amt, long long stock) {
  if (id == n) return amt;
  long long &ans = dp[id][amt][stock];
  if (ans != -1) return ans;
  ans = 0;
  ans = max(ans, res(id + 1, amt, stock));
  for (long long i = 1; i <= amt / v[id]; i++) {
    ans = max(ans, res(id + 1, amt - i * v[id], stock + i));
  }
  ans = max(ans, res(id + 1, amt + stock * v[id], 0));
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  cout << res(0, 1000, 0);
  return 0;
}
