#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n;
int m;
vector<int> vt;
map<tuple<int, int, int>, int> dp;
int rec(int pos, int amt, int stock) {
  if (pos == n) {
    return amt;
  }
  if (dp.count({pos, amt, stock})) {
    return dp[{pos, amt, stock}];
  }
  int ret = rec(pos + 1, amt, stock);
  for (int i = 1;; ++i) {
    if (amt - i * vt[pos] < 0) {
      break;
    }
    ret = max(ret, rec(pos + 1, amt - i * vt[pos], stock + i));
  }
  for (int i = 1; i <= stock; ++i) {
    ret = max(ret, rec(pos + 1, amt + i * vt[pos], stock - i));
  }
  dp[{pos, amt, stock}] = ret;
  return ret;
}
int main() {
  std ::ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vt.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> vt[i];
  }
  int ans = rec(0, 1000, 0);
  cout << ans << endl;
  return 0;
}
