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