



#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int N,K;

int dp[81][2000][2000];
int A[100];

int dpf(int i,int j,int k){
	if (i == N + 1) return k;
	if (dp[i][j][k] != -1) return dp[i][j][k];
	return dp[i][j][k] = max({dpf(i + 1, j + k / A[i], k % A[i]), //Buy
		dpf(i + 1, j, k),
		dpf(i + 1, 0, k + j * A[i]),
		k
	});
	
	
	
}
int32_t main(){
	fast;
	cin>>N;
	FOR(i,1,N) cin>>A[i];
	mem(dp,-1);
	cout<<dpf(1,0,1000);
}

