#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), co(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  co = a;
  sort(co.rbegin(), co.rend());
  for (int i = 0; i < (n); i++) {
    int cnt = 0;
    while (true) {
      if (a[i] != co[cnt]) {
        cout << co[cnt] << endl;
        break;
      } else if (cnt == n - 1) {
        cout << co[i] << endl;
        break;
      } else {
        cnt++;
      }
    }
  }
  return 0;
}
