#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i = 0; i < N; i++) {
    auto erase_num = A[i];
    A[i] = 0;
    auto maxIt = max_element(A.begin(), A.end());
    auto maxIndex = distance(A.begin(), maxIt);
    cout << A[maxIndex] << endl;
    A[i] = erase_num;
  }
}
