#include <bits/stdc++.h>
using namespace std;
const int maxM = 2e5 + 7;
const int maxV = 90010;
const int MOD = 1e9 + 7;
int T;
const int maxN = 1e2 + 8;
const long long INF = 1000000000000000010LL;
const int K = 15;
int n;
int a[maxN];
int b[maxN];
int c[maxN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  b[1] = a[1];
  for (int i = 2; i <= n; i++) {
    b[i] = max(b[i - 1], a[i]);
  }
  c[n] = a[n];
  for (int i = n - 1; i >= 1; i--) {
    c[i] = max(c[i + 1], a[i]);
  }
  for (int i = 1; i <= n; i++) {
    int L = 0, R = 0;
    if (i - 1 >= 1) L = b[i - 1];
    if (R + 1 <= n) R = c[i + 1];
    int ans = max(L, R);
    cout << ans << endl;
  }
  return 0;
}
