#include <bits/stdc++.h>
using namespace std;
int n;
int a[101];
int dp[81][1001][101];
int f(int i, int m, int s) {
  if (i >= n) return m;
  if (dp[i][m][s] != -1) return dp[i][m][s];
  int b = m / a[i];
  int& ans = dp[i][m][s];
  ans = 0;
  for (int j = 0; j <= b; j++) {
    ans = max(ans, f(i + 1, m - (j * a[i]), s + j));
  }
  for (int k = 0; k <= s; k++) {
    ans = max(ans, f(i + 1, m + (a[i] * k), s - k));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 1000;
  memset(dp, -1, sizeof dp);
  cout << max(ans, f(0, 1000, 0));
  return 0;
}
