#include <bits/stdc++.h>
using namespace std;
int n, s[200001], u[200001];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i], u[i] = s[i];
  sort(s + 1, s + n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = n; j >= 1; j--)
      if (s[j] != u[i]) {
        cout << s[j] << endl;
        break;
      }
  }
  return 0;
}
