#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i = 0; i < N; i++) {
    int max_num = -1;
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      max_num = max(A[j], max_num);
    }
    cout << max_num << endl;
  }
  return 0;
}
