#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, a[200000], max;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int j = 0; j < n; j++) {
    max = 0;
    for (int i = 0; i < n; i++) {
      if (i != j && max < a[i]) {
        max = a[i];
      }
    }
    cout << max << endl;
  }
}
