#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (n); i++) cin >> a[i];
  int dekai = 0;
  int hozon;
  for (int i = 0; i < (n); i++) {
    hozon = a[i];
    a[i] = 0;
    for (int j = 0; j < (n - 1); j++) {
      dekai = max(a[j], a[j + 1]);
    }
    a[i] = hozon;
    cout << dekai << endl;
  }
}
