#include <bits/stdc++.h>
int main(void) {
  int n;
  int a[200000] = {0};
  int max[200000] = {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 (j != i && max[i] < a[j]) {
        max[i] = a[j];
      }
    }
    printf("%d\n", max[i]);
  }
  return 0;
}
