#include <bits/stdc++.h>
using namespace std;
void parseArray(long long* A, long long n) {
  for (long long K = 0; K < n; K++) {
    cin >> A[K];
  }
}
long long modInverse(long long a, long long b) {
  return 1 < a ? b - modInverse(b % a, a) * b / a : 1;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long double dist(long double x, long double y, long double a, long double b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
void debug(long long* a, long long n) {
  for (long long k = 0; k < n; k++) {
    cerr << a[k] << " ";
  }
  cout << "\n";
}
long long n;
long long a[80];
long long memo[80][1000 + 200 * 80][1000 / 100];
long long dp(long long day, long long money, long long shares) {
  if (day == n) return money;
  if (memo[day][money][shares] != -1) return memo[day][money][shares];
  long long ans = money;
  long long amount = 0;
  for (int k = 0; k <= shares; k++)
    ans = max(ans, dp(day + 1, money + k * a[day], shares - k));
  while (amount * a[day] <= money) {
    ans = max(ans, dp(day + 1, money - amount * a[day], shares + amount));
    amount++;
  }
  return memo[day][money][shares] = ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  parseArray(a, n);
  memset(memo, -1, sizeof memo);
  cout << dp(0, 1000, 0) << endl;
  return 0;
}
