#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const double pi = acos(-1.0);
int main(void) {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort((b).begin(), (b).end());
  reverse((b).begin(), (b).end());
  for (long long i = 0; i < (n); ++i)
    for (long long j = 0; j < (n); ++j) {
      if (a[i] != b[j]) {
        cout << b[j] << endl;
        break;
      }
    }
  return 0;
}
