#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[200005];
  int c[200005];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[i] = a[i];
  }
  for (int i = 0; i < n; i++) {
    sort(c, c + n);
    if (c[n - 1] == a[i]) {
      cout << c[n - 2] << endl;
    } else {
      cout << c[n - 1] << endl;
    }
  }
}
