#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a) out << it << " ";
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  return in >> a.first >> a.second;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a) in >> i;
  return in;
}
ifstream cinn("in.in");
ofstream coutt("out.out");
long long poww(const long long &a, long long b,
               const long long &m = 1000000007) {
  if (b == 0) return 1;
  long long x = poww(a, b / 2, m);
  x = x * x % m;
  if (b & 1) x = x * a % m;
  return x;
}
long long ceil(const long long &a, const long long &b) {
  return (a + b - 1) / b;
}
long long n, dp[80][2001][201];
vector<long long> v;
long long f(long long i, long long bal, long long stk) {
  if (bal < 0) return -(1e18);
  if (i == n) return bal;
  long long &ans = dp[i][bal][stk];
  if (ans != -1) return ans;
  ans = 0;
  for (long long j = 0; j <= bal / v[i]; j++) {
    for (long long k = 0; k <= stk; k++) {
      ans = max(ans, f(i + 1, bal - j * v[i] + k * v[i], stk + j - k));
    }
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> n;
  v = vector<long long>(n);
  cin >> v;
  cout << f(0, 1000, 0);
}
