#include <bits/stdc++.h>
using namespace std;
int arr[200005];
int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    int maxinum = 0;
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      if (arr[j] > maxinum) maxinum = arr[j];
    }
    cout << maxinum << endl;
  }
  return 0;
}
