#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<int> A;
  vector<int> res;
  cin >> N;
  A.resize(N);
  res.resize(N);
  for (size_t idx = 0; idx < N; ++idx) {
    cin >> A[idx];
  }
  for (size_t i = 0; i < N; ++i) {
    int minima = -1;
    for (size_t j = 0; j < N; ++j) {
      if (i == j) continue;
      if (A[j] > minima) minima = A[j];
    }
    res[i] = minima;
  }
  for (size_t i = 0; i < N; ++i) {
    cout << res[i] << endl;
  }
  return 0;
}
