#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), o(n);
  for (auto idx(0); idx < n; ++idx) {
    cin >> a[idx];
    o[idx] = a[idx];
  }
  sort(a.begin(), a.end(), greater<int>());
  for (auto idx(0); idx < n; ++idx) {
    auto itr = find(a.begin(), a.end(), o[idx]);
    if (itr != a.begin())
      cout << *(a.begin()) << "\n";
    else
      cout << *(itr + 1) << "\n";
  }
  cout << endl;
}
