#include <bits/stdc++.h>
using namespace std;
using mii = map<int, int>;
using mll = map<long long int, long long int>;
using pii = pair<int, int>;
using pll = pair<long long int, long long int>;
using vi = vector<int>;
using vll = vector<long long int>;
const int mod = 1000000007;
long long int desc(long long int x, long long int y) { return x > y; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, n;
  cin >> n;
  vll a(n, 0);
  vll b(n, 0);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end(), desc);
  vll c(n, 0);
  auto it = b.begin();
  for (i = 0; i < n; i++) {
    if (a[i] != *it)
      c[i] = *it;
    else {
      while (it != b.end() - 1 && a[i] == *it) it++;
      c[i] = *it;
      it = b.begin();
    }
  }
  for (i = 0; i < n; i++) cout << c[i] << '\n';
  return 0;
}
