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