#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& v : A) {
    cin >> v;
  }
  for (int i = 0; i < N; ++i) {
    vector<int> temp(A);
    temp.erase(temp.begin() + i);
    cout << *max_element(temp.begin(), temp.end()) << endl;
  }
  return 0;
}
