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