#include <bits/stdc++.h>
using namespace std;
static const int INF = 1e+9 + 7;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = (0); i < (N); ++i) {
    cin >> A[i];
  }
  vector<long long> AS = A;
  sort((AS).begin(), (AS).end());
  for (long long i = (0); i < (N); ++i) {
    for (long long j = (N - 1); j >= (0); --j) {
      if (A[i] != AS[j]) {
        cout << (AS[j]) << "\n";
        break;
      }
      if (j == 0) cout << (A[0]) << "\n";
    }
  }
  return 0;
}
