#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  long long ans = 0;
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < (long long)(N); i++) cin >> A[i];
  vector<long long> B;
  for (long long i = 0; i < (long long)(N); i++) {
    B = A;
    B.erase(B.begin() + i);
    sort(B.begin(), B.end());
    cout << *(B.end() - 1) << "\n";
  }
  return 0;
}
