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