#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 69;
const long long mod = 2111992;
long long a[maxn], rg[maxn];
int n;
long long dp[81][10000][100];
long long maxx = 0;
long long dq(int pos, long long val, int have) {
  if (dp[pos][val][have] != -1) return dp[pos][val][have];
  if (pos == n + 1) {
    return val;
  }
  long long ans = 0;
  for (int i = 0; i <= val / a[pos]; i++) {
    for (int j = 0; j <= have + i; j++) {
      ans = max(ans, dq(pos + 1, val - a[pos] * i + j * a[pos], have + i - j));
    }
  }
  return dp[pos][val][have] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << dq(1, 1000, 0);
}
