#include <bits/stdc++.h>
using namespace std;
int dirx[] = {1, -1, 0, 0}, diry[] = {0, 0, 1, -1};
long long bigmod(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * x) % 998244353;
    x = (x * x) % 998244353;
    p >>= 1;
  }
  return res;
}
vector<int> inp(100);
int dp[100][200][20000], n;
int rec(int pos, int stk, int taka) {
  if (pos >= n) return taka;
  if (dp[pos][stk][taka] != -1) return dp[pos][stk][taka];
  int ans = 0;
  for (int i = 0; i <= stk; i++)
    ans = max(ans, rec(pos + 1, stk - i, taka + inp[pos] * i));
  for (int i = 0; i * inp[pos] <= taka; i++)
    ans = max(ans, rec(pos + 1, stk + i, taka - i * inp[pos]));
  return dp[pos][stk][taka] = ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> inp[i];
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, 1000);
  return 0;
}
