#include <bits/stdc++.h>
using namespace std;
int a[200000 + 1];
int b[200000 + 1];
int huan;
int mmax(int x) {
  huan = max(huan, x);
  return huan;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) b[i] = a[i];
  for (int i = 1; i <= n; ++i)
    cout << max(mmax(a[i - 1]), *max_element(a + i + 1, a + n + 1)) << endl;
  return 0;
}
