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