#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, int> a, const pair<int, int> b) {
  return a.second < b.second;
}
const int MAX = 510000;
const int MOD = 1000000007;
int main() {
  int N;
  vector<int> A;
  int ori[200000] = {0};
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
    ori[i] = a;
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    int del = ori[i];
    if (del != A[N - 1]) {
      cout << A[N - 1] << endl;
    } else {
      auto ind = lower_bound(A.begin(), A.end(), del);
      if (ind == A.begin())
        cout << *ind << endl;
      else
        cout << *(ind - 1) << endl;
    }
  }
  return 0;
}
