#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cm = 0, cm2 = 0;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.rbegin(), b.rend());
  for (int i = 0; i < (int)(n); i++) {
    if (a[i] == b[0]) cout << b[1] << endl;
    cout << b[0] << endl;
  }
}
