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