#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> vec(N);
  vector<long long> v(N);
  for (long long i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  v = vec;
  for (long long i = 0; i < N; i++) {
    v.erase(v.begin() + i);
    sort(v.begin(), v.end());
    cout << v.at(N - 2) << endl;
    v = vec;
  }
}
