#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, t, maxi = 0;
  vector<int> A, A_copy;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> t;
    A_copy.push_back(t);
  }
  for (int i = 0; i < N; i++) {
    maxi = 0;
    A = A_copy;
    A.erase(A.begin() + i);
    sort(A.begin(), A.end());
    cout << A[N - 2] << endl;
  }
  return 0;
}
