#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
  x = 0;
  T fh = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fh = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  x *= fh;
}
inline void d_read(double &x) {
  x = 0.0;
  int fh = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fh = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
  if (ch == '.') {
    double num = 1.0;
    ch = getchar();
    for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
  }
  x *= fh;
}
template <typename T>
inline void wt(T x) {
  if (x > 9) wt(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  wt(x);
  putchar(c);
}
const int N = 105;
int a[N];
struct info {
  int m[505], len;
} t;
inline info pls(info x, info y) {
  memset(t.m, 0, sizeof(t.m));
  t.len = max(x.len, y.len);
  for (int i = 1; i <= t.len; i++) {
    t.m[i] = x.m[i] + y.m[i];
  }
  for (int i = 1; i <= t.len; i++) {
    if (t.m[i] > 9) {
      t.m[i + 1] += t.m[i] / 10;
      t.m[i] %= 10;
    }
  }
  while (t.m[t.len + 1]) t.len++;
  return t;
}
inline info mul(info x, int y) {
  memset(t.m, 0, sizeof(t.m));
  t.len = x.len;
  for (int i = 1; i <= t.len; i++) {
    t.m[i] = x.m[i] * y;
  }
  t.len += 200;
  for (int i = 1; i <= t.len; i++) {
    if (t.m[i] > 9) {
      t.m[i + 1] += t.m[i] / 10;
      t.m[i] %= 10;
    }
  }
  while (!t.m[t.len] && t.len) t.len--;
  return t;
}
inline info div(info x, int y) {
  memset(t.m, 0, sizeof(t.m));
  t.len = x.len;
  int res = 0;
  for (int i = t.len; i >= 1; i--) {
    res = (res * 10) + x.m[i];
    if (res > y) {
      t.m[i] = res / y;
      res %= y;
    }
  }
  while (!t.m[t.len] && t.len) t.len--;
  return t;
}
inline info str(info x, info y) {
  memset(t.m, 0, sizeof(t.m));
  t.len = max(x.len, y.len);
  for (int i = 1; i <= t.len; i++) {
    if (x.m[i] < y.m[i]) {
      x.m[i + 1]--;
      x.m[i] += 10;
    }
    t.m[i] = x.m[i] - y.m[i];
  }
  while (!t.m[t.len] && t.len) t.len--;
  return t;
}
int main() {
  int n;
  readin(n);
  for (int i = 1; i <= n; i++) {
    readin(a[i]);
  }
  info res, st;
  res.m[1] = 1;
  res.len = 1;
  res = mul(res, 1000);
  a[0] = 1e9;
  for (int i = 1; i <= n; i++) {
    if (a[i] >= a[i - 1] && a[i] > a[i + 1]) {
      res = pls(res, mul(st, a[i]));
      st.len = 0;
      memset(st.m, 0, sizeof(st.m));
    } else if (a[i] <= a[i - 1] && a[i] < a[i + 1]) {
      st = div(res, (1ll * a[i]));
      res = str(res, mul(st, a[i]));
    }
  }
  for (int i = res.len; i >= 1; i--) putchar(res.m[i] + 48);
  putchar('\n');
  return 0;
}
