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