#include <bits/stdc++.h>
using namespace std;
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(vector<T> v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void bug() { cerr << "\n"; }
template <typename Head, typename... Tail>
void bug(Head H, Tail... T) {
  cerr << " " << to_string(H);
  bug(T...);
}
const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;
int dp[81][81 * 201][201];
int n, a[81];
int fun(int i, int money, int stocks) {
  if (i == n) return money;
  if (money < 0 || stocks < 0) return -INF;
  int& ans = dp[i][money][stocks];
  if (ans != -1) {
    return ans;
  }
  int cur = money / a[i];
  for (int j = 0; j <= cur; j++) {
    ans = max(ans, fun(i + 1, money - j * a[i], stocks + j));
  }
  int cur_stocks = stocks;
  for (int j = 0; j <= cur_stocks; j++) {
    ans = max(ans, fun(i + 1, money + j * a[i], stocks - j));
  }
  return ans;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof dp);
  cout << fun(0, 1000, 0);
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int tc = 1;
  for (int t = 1; t <= tc; t++) {
    solve();
  }
}
