#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.push_back(make_pair(i, x));
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    int t = 0;
    if (s[t].first != i) {
      cout << s[t].second << endl;
    } else {
      cout << s[t + 1].second << endl;
    }
  }
  return 0;
}
