#include <bits/stdc++.h>
using namespace std;
void max_print(int a[], int num, int n) {
  int max = 0;
  for (int i = 0; i < n; i++) {
    if (i != num) {
      if (max < a[i]) {
        max = a[i];
      }
    }
  }
  cout << max << "\n";
}
int main(void) {
  int n, a[200000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    max_print(a, i, n);
  }
  return 0;
}
