#include <bits/stdc++.h>
using namespace std;
const long long limit = (long long)(1e9 + 7);
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while (long long r = a % b) a = b, b = r;
  return b;
}
class mod {
 public:
  long long val;
  mod(long long v) { val = v % limit; }
  mod() { val = 0; }
  const mod operator-(const mod &v) const {
    mod ret(v.val);
    ret -= val;
    return ret;
  }
  const mod operator+(const mod &v) const {
    mod ret(v.val);
    ret += val;
    return ret;
  }
  void operator-=(const mod &v) {
    val -= v.val;
    if (val < 0) val += limit;
  }
  void operator+=(const mod &v) {
    if (val + v.val >= limit) val -= limit;
    val += v.val;
  }
  void operator+=(long long &v) {
    if (val + v >= limit) val -= limit;
    val += v;
  }
  void operator*=(const mod &v) {
    val *= v.val;
    val %= limit;
  }
  void operator*=(long long &v) {
    val *= v;
    val %= limit;
  }
  long long modinv(long long a) {
    long long b = limit, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    u %= limit;
    if (u < 0) u += limit;
    return u;
  }
  void operator/=(const mod &v) {
    val *= modinv(v.val);
    val %= limit;
  }
  void operator/=(long long &v) {
    val *= modinv(v);
    val %= limit;
  }
};
struct UnionFind {
  vector<int> par;
  vector<int> childN;
  long long r = 0;
  UnionFind(int N) : par(N), childN(N) {
    for (int i = 0; i < N; i++) par[i] = i, childN[i] = 1;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
    r -= childN[rx] * (childN[rx] - 1) / 2;
    r -= childN[ry] * (childN[ry] - 1) / 2;
    childN[ry] += childN[rx];
    childN[rx] = 0;
    r += childN[ry] * (childN[ry] - 1) / 2;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
class WarshallFloyd {
 public:
  vector<vector<int>> d;
  int n;
  WarshallFloyd(int _n) : n(_n) { d.resize(n, vector<int>(n, limit)); }
  void run() {
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          if (d[i][k] < limit && d[k][i] < limit)
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
};
using ipair = pair<int, pair<int, int>>;
bool operator>(const ipair a, const ipair b) { return a.first > b.first; };
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };
using xpair = pair<int, int>;
bool operator>(const xpair &a, const xpair &b) {
  return a.second > b.second || (a.second == b.second && a.first > b.first);
};
bool operator<(const xpair &a, const xpair &b) {
  return a.second < b.second || (a.second == b.second && a.first > b.first);
};
bool operator==(const xpair &a, const xpair &b) { return a.first == b.first; };
int bn = 0;
vector<pair<int, int>> b;
long long r = 1000;
void func(long long m, long long kabu, int i) {
  if (i == bn - 1) {
    long long k =
        kabu * b[i].second + (m / b[i].first) * b[i].second + m % b[i].first;
    if (r < k) r = k;
    return;
  }
  func(m % b[i].first, kabu + m / b[i].first, i + 1);
  func(m, kabu, i + 1);
  func(kabu * b[i].second + (m / b[i].first) * b[i].second + m % b[i].first, 0,
       i + 1);
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  bool up = a[1] - a[0] > 0;
  int head = 0;
  for (int i = 2; i < n; i++) {
    bool k = a[i] - a[i - 1] > 0;
    if (k == up) continue;
    if (up) b.push_back(make_pair(a[head], a[i - 1]));
    head = i - 1;
    up = k;
  }
  if (up) b.push_back(make_pair(a[head], a[n - 1]));
  bn = b.size();
  if (bn > 0) func(1000, 0, 0);
  printf("%lld", r);
  return 0;
}
