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