#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, n, sonomama[200000], changed[200000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> changed[i];
    sonomama[i] = changed[i];
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (changed[i] < changed[j]) swap(changed[i], changed[j]);
    }
  }
  for (i = 0; i < n; i++) {
    if (changed[0] == sonomama[i])
      cout << changed[0] << endl;
    else
      cout << changed[1] << endl;
  }
  return 0;
}
