#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int b[n + 1];
  for (int i = 1; i <= n; ++i) b[i] = a[i];
  sort(b + 1, b + 1 + n);
  for (int i = 0; i < n; ++i)
    if (a[i] < b[n])
      cout << *upper_bound(b + 1, b + n + 1, a[i]) << endl;
    else
      cout << b[n] << endl;
  return 0;
}
