#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100], dp[80][10000][100];
int sol(int i, int cur, int have) {
  if (i == n) return cur;
  int &ret = dp[i][cur][have];
  if (~ret) return ret;
  int ch1 = -1e9, ch2 = -1e9, ch3 = -1e9;
  if (cur >= arr[i]) ch1 = sol(i + 1, cur % arr[i], have + cur / arr[i]);
  if (have) ch2 = sol(i + 1, cur + have * arr[i], 0);
  ch3 = sol(i + 1, cur, have);
  ret = max({ch1, ch2, ch3});
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  cout << sol(0, 1000, 0);
}
