#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> arr;
  arr.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  vector<int> s = arr;
  std::sort(s.begin(), s.end());
  std::vector<int> ret;
  for (int i = 0; i < n; ++i) {
    int mi = n - 1;
    int a = arr[i];
    while (true) {
      int ma = s[mi];
      if (a < ma) {
        ret.push_back(ma);
        break;
      }
      mi--;
      if (mi < 0) {
        ret.push_back(arr[n - 1]);
        break;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ret[i] << endl;
  }
  return 0;
}
