#include <bits/stdc++.h>
using namespace std;
int n;
int maax(int a[200005]) {
  int maxn = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] > maxn) maxn = a[i];
  }
  return maxn;
}
int main() {
  cin >> n;
  int a[200005];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    swap(a[i], a[n]);
    cout << maax(a) << endl;
    swap(a[i], a[n]);
  }
  return 0;
}
