#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;


vector<int> A;
int ans = 0;
int N;

int main(){
    cin >> N;
    A.assign(N,0);
    rep(i,N) cin >> A[i];
    vector<vector<vector<bool>>> dp(N+1, vector<vector<bool>>(50, vector<bool>(50000,false)));
    dp[0][0][1000] = true;

    rep(i,N){
        rep(j,50){
            //cout << j << endl;
            rep(k,50000){
                
                dp[i+1][j][k] = dp[i+1][j][k] | dp[i][j][k];
                int sold_money = k + j*A[i];
                if (sold_money < 50000){
                    //cout << "sold" << endl;
                    dp[i+1][0][sold_money] = dp[i+1][0][sold_money] | dp[i][j][k];
                }
                int buy_count = j + k/A[i];
                int money = k - A[i] * (k/A[i]);
                if (buy_count < 50 && money < 50000){
                    /*
                    cout << "buy" << endl;
                    cout << buy_count << endl;
                    cout << money << endl;
                    */
                    dp[i+1][buy_count][money] = dp[i+1][buy_count][money] | dp[i][j][k];
                }
            }
        }
    }
    int ans = 0;
    rep(j,50){
        rep(k,50000){
            if (dp[N][j][k]) ans = max(ans, k);
        }
    }

    cout << ans << endl;
}

