#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using v2 = vector<vector<T>>;
template <typename T>
inline v2<T> fill(int r, int c, const T& t) {
  return v2<T>(r, vector<T>(c, t));
}
int n;
map<array<int, 3>, int> dp;
vector<int> a;
int f(int i, int j, int k) {
  if (j < 0 || k < 0) return 0;
  if (i == n) return j;
  if (dp.count({i, j, k})) return dp[{i, j, k}];
  int ans = 0;
  for (int buy = 0; buy <= j / a[i]; ++buy) {
    ans = max(ans, f(i + 1, j - buy * a[i], k + buy));
  }
  for (int sell = 0; sell <= k; ++sell) {
    ans = max(ans, f(i + 1, j + sell * a[i], k - sell));
  }
  return dp[{i, j, k}] = ans;
}
void solve() {
  cin >> n;
  a = vector<int>(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  cout << f(0, 1000, 0) << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
