#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (ll i = 0; i < (ll)(n); i++) {
    cin >> a[i];
  }
  vector<int> k = a;
  sort(k.begin(), k.end());
  reverse(k.begin(), k.end());
  for (auto ai : a) {
    bool flag = true;
    int i = 0;
    while (flag) {
      if (ai != k[i]) {
        cout << k[i] << endl;
        flag = 0;
      } else if (i == k.size() - 1) {
        cout << ai << endl;
        flag = 0;
      }
      i++;
    }
  }
  return 0;
}
