#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const int INF = 1e9;
int main() {
  int n;
  cin >> n;
  vector<vector<set<int>>> g(n + 1, vector<set<int>>(5000, set<int>()));
  g[0][0].insert(1000);
  vector<queue<pair<int, int>>> q(n + 1);
  q[0].push({0, 1000});
  for (int i = 0; i < n; ++i) {
    int price;
    cin >> price;
    for (int j = 0; j < 5000; ++j) {
      for (auto l : g[i][j]) {
        for (int k = 0; k <= l / price; ++k) {
          g[i + 1][j + k].insert(l - (k * price));
        }
        for (int k = 0; k <= j; ++k) {
          g[i + 1][j - k].insert(l + (price * k));
        }
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < 50; ++j) {
    ans = max(*g[n][j].rbegin(), ans);
  }
  cout << ans << endl;
  return 0;
}
