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