#include <bits/stdc++.h>
long long int power(long long int x, long long int b, long long int m) {
  long long int p = 1;
  while (b > 0) {
    if (b & 1) {
      p = p * x;
      p %= m;
    }
    b >>= 1;
    x *= x;
    x %= m;
  }
  return p % m;
}
using namespace std;
struct lex_compare {
  bool operator()(pair<long long int, long long int> p1,
                  pair<long long int, long long int> p2) {
    return p1.first >= p2.first;
  }
};
long long int dp[85][2005][40];
long long int n;
long long int rec(long long int i, long long int money, long long int arr[],
                  long long int stocksleft) {
  if (i == n) {
    return money;
  }
  if (dp[i][money][stocksleft] != -1) return dp[i][money][stocksleft];
  long long int ans = 0;
  for (long long int j = 0; j <= stocksleft; j++) {
    ans = max(ans, rec(i + 1, money + arr[i] * j, arr, stocksleft - j));
  }
  long long int maxbuy = (money / arr[i]);
  for (long long int j = 1; j <= maxbuy; j++) {
    ans = max(ans, rec(i + 1, money - j * arr[i], arr, stocksleft + j));
  }
  return dp[i][money][stocksleft] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  memset(dp, -1, sizeof(dp));
  long long int currp = 1000;
  long long int ans = rec(0, 1000, arr, 0);
  cout << ans << "\n";
  return 0;
}
