#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int* m = max_element(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] < *m)
      cout << *m << endl;
    else {
      int* m1;
      int b = a[i];
      a[i] = 0;
      m1 = max_element(a, a + n);
      a[i] = b;
      cout << *m1 << endl;
    }
  }
  return 0;
}
