#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> P, tmp;
vector<map<pair<long long, long long>, bool>> dp;
int main(void) {
  int N, day = 0, ans = -1000;
  cin >> N;
  vector<int> A(N + 5, 0);
  vector<queue<pair<long long, long long>>> que(N + 5);
  map<pair<long long, long long>, bool> v1;
  vector<map<pair<long long, long long>, bool>> v2(900, v1);
  dp = v2;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  P = make_pair(1000, 0);
  if (dp[day + 1][P] == false) {
    que[day + 1].push(P);
    dp[day + 1][P] = true;
  }
  A[0] = INT_MAX;
  day = 1;
  while (day <= N) {
    P = que[day].front();
    que[day].pop();
    int kabu;
    long long kane;
    if (A[day - 1] > A[day]) {
      tmp = P;
      kabu = tmp.second + tmp.first / A[day];
      kane = tmp.first - A[day] * (tmp.first / A[day]);
      if (day == N) {
        if (kane > ans) {
          ans = kane;
        }
      } else {
        tmp = make_pair(kane, kabu);
        if (dp[day + 1][tmp] == false) {
          que[day + 1].push(tmp);
          dp[day + 1][tmp] = true;
        }
      }
    } else if (A[day - 1] < A[day]) {
      tmp = P;
      kabu = 0;
      kane = P.first + A[day] * P.second;
      if (day == N) {
        if (kane > ans) {
          ans = kane;
        }
      } else {
        tmp = make_pair(kane, kabu);
        if (dp[day + 1][tmp] == false) {
          que[day + 1].push(tmp);
          dp[day + 1][tmp] = true;
        }
      }
    } else {
      tmp = P;
      if (day == N) {
        if (kane > ans) {
          ans = kane;
        }
      } else {
        if (dp[day + 1][tmp] == false) {
          que[day + 1].push(tmp);
          dp[day + 1][tmp] = true;
        }
      }
    }
    if (que[day].size() <= 0) {
      day++;
    }
  }
  cout << ans << endl;
  return 0;
}
