#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end(), greater<long long>());
  long long ma = b[0];
  int j = 0;
  for (j = 0; b[j] == b[0]; j++) {
  }
  for (long long i = 0; i < n; i++) {
    if (a[i] == b[0]) {
      cout << b[j] << endl;
    } else {
      cout << b[0] << endl;
    }
  }
  return 0;
}
