#include <bits/stdc++.h>
using namespace std;
int a[200005], maxn[200005] = {0};
int main() {
  int n, sum = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      maxn[i] = max(maxn[i], a[j]);
    }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", maxn[i]);
  }
  return 0;
}
