#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, a[200001], t, maxi, i;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) {
    t = a[i];
    a[i] = -1;
    cout << *max_element(a, a + n) << endl;
    a[i] = t;
  }
  return 0;
}
