#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    vec[i] = n;
  }
  int tmp;
  int max;
  for (int j = 0; j < N; j++) {
    if (j == 0) {
      tmp = vec[j];
      vec[j] = 0;
      max = *max_element(vec.begin(), vec.end());
      cout << max << endl;
    } else {
      vec[j - 1] = tmp;
      tmp = vec[j];
      vec[j] = 0;
      max = *max_element(vec.begin(), vec.end());
      cout << max << endl;
    }
  }
  return 0;
}
