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