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