#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 18;
const long long maxn = (long long)1e6 + 6;
using namespace std;
long long n;
vector<long long> a, b, ans;
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
    b.push_back(x);
  }
  sort(b.begin(), b.end());
  for (long long i = 0; i < n; i++) {
    long long maxx = b.back();
    if (maxx > a[i])
      ans.push_back(maxx);
    else {
      long long y = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
      if (y > 0)
        ans.push_back(b[y - 1]);
      else
        ans.push_back(b[y]);
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
