// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n; 

int arr[89];
int dp[89][80009][109];
// unordered_map<int, unordered_map<int, unordered_map<int, int > > > dp;

int solve(int idx, int money, int stocks) {
	if(idx == n)
		return money;

	// if(dp.find(idx) != dp.end() &&
	// 	dp[idx].find(money) != dp[idx].end() &&
	// 	dp[idx][money].find(stocks) != dp[idx][money].end())
	if(dp[idx][money][stocks] != -1)
		return  dp[idx][money][stocks];

	int ans = solve(idx + 1, money, stocks);
	
	int t = money / arr[idx];
	if(t > 0) 
		ans = max(ans, solve(idx + 1, money - (t * arr[idx]), stocks + t));

	ans = max(ans, solve(idx + 1, money + (stocks * arr[idx]), 0));
	
	return dp[idx][money][stocks] = ans;
} 

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin>>n;
	for(int i = 0; i < n; i++)
		cin>>arr[i];
	memset(dp, -1, sizeof dp);

	cout<<solve(0, 1000, 0)<<endl;

	return 0;
}