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