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