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