#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for (int i = 0; i < n; i++) {
    int mayor = 0;
    for (int j = 0; j < n; j++) {
      if (i != j && mayor < arr[j]) {
        mayor = arr[j];
      }
    }
    printf("%d\n", mayor);
  }
  return 0;
}
