#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  int temp = 0;
  for (auto i = 0; i < N; i++) cin >> A[i];
  for (auto i = 0; i < N; i++) {
    temp = A[i];
    A[i] = 0;
    cout << *max_element(A.begin(), A.end()) << endl;
    A[i] = temp;
  }
}
