#include <bits/stdc++.h>
using namespace std;
const int maxN = 200000;
int main() {
  long long N;
  long long A[maxN];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    long long tmp = A[i];
    A[i] = 0;
    cout << *max_element(A, A + N) << endl;
    A[i] = tmp;
  }
}
