#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = (0); i < (n); ++i) {
    cin >> vec.at(i);
  }
  for (int i = (0); i < (n); ++i) {
    cerr << "vec.at(i)"
         << " = " << (vec.at(i)) << endl;
  }
  for (int i = (0); i < (n); ++i) {
    vector<int> vec2(n - 1);
    for (int j = (0); j < (n - 1); ++j) {
      if (j < i)
        vec2.at(j) = vec.at(j);
      else if (j >= i)
        vec2.at(j) = vec.at(j + 1);
    }
    for (int k = (0); k < (n - 1); ++k) {
      cerr << "vec2.at(k)"
           << " = " << (vec2.at(k)) << endl;
    }
    int max = *max_element((vec2).begin(), (vec2).end());
    cout << max << endl;
  }
  return 0;
}
