#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), p(n);
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    p[i] = a[i];
  }
  sort(p.begin(), p.end());
  int ai;
  for (int i = 0; i < (n); i++) {
    ai = a[i];
    if (ai == p[n - 1]) {
      auto iter = lower_bound(p.begin(), p.end(), ai);
      int dist = distance(p.begin(), iter);
      if (dist == 0) {
        dist += 1;
      }
      cout << p[dist - 1] << endl;
    } else {
      cout << p[n - 1] << endl;
    }
  }
  return 0;
}
