#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) {
      if (i != j) b.push_back(a[j]);
    }
    sort(b.begin(), b.end(), greater<int>());
    cout << b[0] << endl;
    b.clear();
  }
}
