#include <bits/stdc++.h>
using namespace std;
long long a[200050], ai[200050];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ai[i] = a[i];
  }
  　　sort(a, a + n, greater<int>());
  for (int i = 0; i < n; i++) {
    if (a[0] == ai[i])
      cout << a[1] << '\n';
    else
      cout << a[0] << '\n';
  }
  return 0;
}
