#include <bits/stdc++.h>
int a[111000], b[111000], n;
using namespace std;
int main() {
  cin >> n;
  for (int x = 1; x <= n; x++) {
    cin >> a[x];
    b[x] = a[x];
  }
  sort(b + 1, b + 1 + n);
  for (int x = 1; x <= n; x++) {
    if (a[x] == b[n]) {
      cout << b[n - 1] << endl;
    } else {
      cout << b[n] << endl;
    }
  }
}
