#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int N;
  int A[200000];
  int m = 0;
  scanf("%d\n", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d\n", &A[i]);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        continue;
      } else {
        if (m < A[j]) {
          m = A[j];
        }
      }
    }
    printf("%d\n", m);
    m = 0;
  }
  return 0;
}
