#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> vec1(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
    vec1[i] = vec[i];
  }
  int max = *max_element(vec.begin(), vec.end());
  for (int i = 0; i < (int)(N); i++) {
    if (vec1[i] == max) {
      sort(vec.begin(), vec.end());
      cout << vec[N - 2] << endl;
    } else
      cout << max << endl;
  }
}
