#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592654;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long tc, l, k, sum = 0, x = 0, y, z = 0, m = 1, n = 0, ans = 0, cnt = 0;
  cin >> n;
  long long arr[n];
  for (auto &i : arr) cin >> i;
  sort(arr, arr + n);
  for (long long i = 0; i < n; i++) {
    if (i == n - 1)
      cout << arr[n - 2] << "\n";
    else
      cout << arr[n - 1] << "\n";
  }
}
