#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<pair<long long, long long> > box(0);
  box.push_back(pair<long long, long long>(A.at(0), A.at(0)));
  for (int i = 1; i < N; i++) {
    long long bf = box.back().first, bs = box.back().second;
    if (A.at(i) == A.at(i - 1))
      continue;
    else if (A.at(i) > A.at(i - 1)) {
      if (bf == bs) {
        box.back().second = A.at(i);
      } else if (bf > bs) {
        box.push_back(pair<long long, long long>(bs, A.at(i)));
      } else {
        chmax(box.back().second, A.at(i));
      }
    } else {
      if (bf == bs) {
        box.back().second = A.at(i);
      } else if (bf > bs) {
        chmin(bs, A.at(i));
      } else {
        box.push_back(pair<long long, long long>(box.back().second, A.at(i)));
      }
    }
  }
  for (auto x : box) {
    cout << x.first << ' ' << x.second << "\n";
  }
  long long money = 1000LL;
  long long stock = 0LL;
  for (int i = 0; i < int(box.size()); i++) {
    if (i == int(box.size()) - 1 && box.at(i).first >= box.at(i).second) break;
    if (box.at(i).first == box.at(i).second) continue;
    if (box.at(i).first < box.at(i).second) {
      long long n = money / box.at(i).first;
      money -= n * box.at(i).first;
      stock += n;
      money += stock * box.at(i).second;
      stock = 0;
    }
  }
  cout << money << "\n";
}
