#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];
  }
  for (int i = 0; i < N; i++) {
    vector<long long> _A = A;
    _A.erase(_A.begin() + i);
    cout << *max_element(_A.begin(), _A.end()) << endl;
  }
}
