#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, string>;
using Map = map<string, ll>;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    vector<ll> B(0);
    for (int j = 0; j < N; j++) {
      if (j != i) {
        B.emplace_back(A[j]);
      }
    }
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    cout << B[0] << endl;
    ;
  }
  return 0;
}
