#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long max_A = *max_element(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (max_A != A[i] || count(A.begin(), A.end(), A[i]) >= 2) {
      cout << max_A << endl;
      continue;
    }
    vector<long long> _A = A;
    _A.erase(_A.begin() + i);
    cout << *max_element(_A.begin(), _A.end()) << endl;
  }
}
