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