#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
int main(void) {
  long long N;
  long long ans = 0;
  cin >> N;
  multiset<long long> ml;
  vector<long long> A(N);
  long long tmp;
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> tmp;
    A[i] = tmp;
    ml.insert(tmp);
  }
  multiset<long long> ml_tmp;
  for (long long i = 0; i < (long long)(N); i++) {
    ml_tmp = ml;
    ml_tmp.erase(ml_tmp.find(A[i]));
    cout << *(ml_tmp.rbegin()) << "\n";
  }
  return 0;
}
