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