#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[200010];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    int B[200010];
    for (int k = 0; k < N; k++) {
      B[k] = A[k];
    }
    B[i] = 0;
    sort(B, B + N);
    cout << B[N - 1] << endl;
  }
}
