#include <bits/stdc++.h>
using namespace std;
int maximum(int N, vector<int>& vec, int nocnt);
int main() {
  int N;
  cin >> N;
  vector<int> a(N, 0);
  int cnt, max, max2;
  int tmp_a;
  for (cnt = 0; cnt < N; cnt++) {
    cin >> a[cnt];
  }
  for (cnt = 0; cnt < N; cnt++) {
    cout << maximum(N, a, cnt) << endl;
  }
  return 0;
}
int maximum(int N, vector<int>& vec, int nocnt) {
  int cnt, max;
  if (nocnt)
    max = vec[0];
  else
    max = vec[1];
  for (cnt = 0; cnt < N; cnt++) {
    if (cnt != nocnt) {
      if (vec[cnt] > max) max = vec[cnt];
    }
  }
  return max;
}
