#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, a[200020], s[200020], q;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i] = a[i];
  }
  for (int j = 0; j < n; j++) {
    sort(a, a + n, cmp);
    if (s[j] == a[0]) {
      cout << a[1] << endl;
    } else {
      cout << a[0] << endl;
    }
  }
  return 0;
}
