#include <bits/stdc++.h>
using namespace std;
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B.begin(), B.end());
  for (int i = 0; i < (N); ++i) {
    int a = A[i];
    int count = 0;
    for (int j = N - 1; j >= 0; --j) {
      if (a < B[j]) {
        cout << B[j] << endl;
        break;
      }
      if (a == B[j]) {
        if (count == 0) {
          count++;
          continue;
        } else {
          cout << B[j] << endl;
          break;
        }
      }
      cout << B[j] << endl;
    }
  }
  return 0;
}
