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