#include <bits/stdc++.h>
using namespace std;
int n;
int dp[81][17001][171];
int ar[81];
int func(int ind, int m, int s) {
  if (ind == n) return m;
  if (dp[ind][m][s] != -1) return dp[ind][m][s];
  int i, ret = 0;
  for (i = 0; i <= s; i++) {
    ret = max(ret, func(ind + 1, m + i * ar[ind], s - i));
  }
  for (i = 0; i <= m / ar[ind]; i++) {
    ret = max(ret, func(ind + 1, m - i * ar[ind], s + i));
  }
  return dp[ind][m][s] = ret;
}
int main() {
  int i, j, k, m, t;
  cin >> n;
  for (i = 0; i < n; i++) cin >> ar[i];
  for (i = 0; i <= 80; i++) {
    for (j = 0; j <= 17000; j++) {
      for (k = 0; k <= 170; k++) dp[i][j][k] = -1;
    }
  }
  cout << func(0, 1000, 0);
}
