#include <bits/stdc++.h>
using namespace std;
const int MAXN = 212345;
int L[MAXN], R[MAXN], a[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    L[i] = max(a[i - 1], L[i - 1]);
    R[i] = max(a[i + 1], R[i + 1]);
  }
  for (int i = 1; i <= n; ++i) printf("%d\n", max(L[i], R[i]));
  return 0;
}
