#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j;
  cin >> n;
  long long a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (i = 0; i < n; i++) {
    long long max = 0;
    for (j = 0; j < n; j++) {
      if (b[j] != a[i]) {
        if (b[j] >= max) max = a[j];
      }
    }
    cout << max << endl;
  }
}
