#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long int mod = 1e9 + 7;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int powm(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * 1LL * a) % mod;
    b >>= 1LL;
    a = (a * 1LL * a) % mod;
  }
  return res;
}
int n;
int a[100];
int dp[81][2005][200];
int solve(int day, int rs, int st) {
  if (day == n + 1) return rs;
  if (dp[day][rs][st] != -1) {
    return dp[day][rs][st];
  }
  dp[day][rs][st] = 0;
  int canbuy = rs / a[day];
  for (int i = 0; i <= canbuy; i++) {
    dp[day][rs][st] =
        max(dp[day][rs][st], solve(day + 1, rs - (i * a[day]), st + i));
  }
  for (int i = 0; i <= st; i++) {
    dp[day][rs][st] =
        max(dp[day][rs][st], solve(day + 1, rs + i * a[day], st - i));
  }
  return dp[day][rs][st];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof dp);
  cout << solve(1, 1000, 0) << '\n';
  return 0;
}
