#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *A;
  A = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int mx;
  for (int i = 0; i < n; i++) {
    mx = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (A[j] > mx) mx = A[j];
    }
    cout << mx << endl;
  }
  delete A;
  return 0;
}
