#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < (n); ++i) cin >> a[i];
  ll max = 0;
  ll mmax = 0;
  for (int i = 0; i < (n); ++i) {
    if (a[i] >= max) {
      max = a[i];
    }
  }
  for (int i = 0; i < (n); ++i) {
    if (a[i] < max) {
      cout << max << endl;
    } else {
      for (int j = 0; j < (n); ++j) {
        if (a[j] >= mmax && i != j) {
          mmax = a[j];
        }
      }
      cout << mmax << endl;
    }
  }
  return 0;
}
