#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const int N = 1e5 + 7, M = 1e4;
int n;
int arr[N], dp[M][100][100];
int solve(int i, int rem, int num) {
  if (i == n) return 0;
  int &ret = dp[i][rem][num];
  if (~ret) return ret;
  ret = max(ret, max(solve(i + 1, rem, num),
                     max(solve(i + 1, rem + num * arr[i], 0) + num * arr[i],
                         solve(i + 1, rem % arr[i], num + (rem / arr[i])) -
                             (arr[i] * (rem / arr[i])))));
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie();
  cin >> n;
  for (int i = 0; i < 80; i++)
    for (int j = 0; j < 10000; j++)
      for (int k = 0; k < 100; k++) dp[j][i][k] = -1;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << 1000 + solve(0, 1000, 0);
}
