#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n], s[n];
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    arr[i] = s[i];
  }
  sort(arr, arr + n);
  for (long long i = 0; i < n; i++) {
    for (long long j = n - 1; j >= 0; j--) {
      if (arr[j] != s[i]) {
        cout << arr[j] << endl;
        break;
      }
    }
  }
}
