#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;
const int mod = 1000000007;
bool dp[88][11][1610];
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  dp[0][0][1000] = true;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (11); ++j) {
      for (int k = 0; k < (1610); ++k) {
        if (dp[i][j][k]) {
          int buy = 0;
          while (k - buy * a[i] >= 0) {
            dp[i + 1][j + buy][k - buy * a[i]] = true;
            ++buy;
          }
          int sell = 1;
          while (j - sell > 0) {
            dp[i + 1][j - sell][k + sell * a[i]] = true;
            ++sell;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < (11); ++j)
    for (int k = 0; k < (1601); ++k) {
      if (dp[n][j][k]) ans = max(ans, k + j * a[n - 1]);
    }
  cout << ans << endl;
  return 0;
}
