#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, max = -1;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j != i && A[j] > max) {
        max = A[j];
      }
    }
    cout << max << endl;
    max = -1;
  }
  return 0;
}
