#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mx;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int j = 0; j < n; j++) {
    mx = -1;
    for (int k = 0; k < n; k++) {
      if (k != j) {
        if (mx < arr[k]) mx = arr[k];
      }
    }
    cout << mx << endl;
  }
  return 0;
}
