#include <bits/stdc++.h>
using namespace std;
int main() {
  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(a.begin(), a.end());
  if (a[0] == a[n - 1]) {
    cout << a[0] << endl;
    return 0;
  }
  for (int j = 0; j < n; ++j) {
    for (int k = 1; k < n; ++k) {
      if (b[j] != a[n - k]) {
        cout << a[n - k] << endl;
        break;
      }
    }
  }
}
