#include <bits/stdc++.h>
using namespace std;
int memo[200005];
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < n; ++j) {
      if (i != j && memo[j] < a) {
        memo[j] = a;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << memo[i] << endl;
  }
  return 0;
}
