#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;
  priority_queue<long long> pq;
  vector<long long> A(N);
  long long tmp;
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> tmp;
    A[i] = tmp;
    pq.push(tmp);
  }
  priority_queue<long long> pq_tmp;
  for (long long i = 0; i < (long long)(N); i++) {
    pq_tmp = pq;
    if (A[i] != pq_tmp.top()) {
      cout << pq_tmp.top() << "\n";
    } else {
      pq_tmp.pop();
      cout << pq_tmp.top() << "\n";
    }
  }
  return 0;
}
