#include <bits/stdc++.h>
using namespace std;
long long func(long long x, vector<long long> X) {
  X.at(x) = 0;
  sort(X.begin(), X.end());
  return X.at(X.size() - 1);
}
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    B.at(i) = func(i, A);
  }
  for (int i = 0; i < N; i++) cout << B.at(i) << endl;
}
