#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  int a[(int)1e5 + 1], n;
  cin >> n;
  int max = 0, place = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
      place = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i != place)
      cout << max << " ";
    else {
      int temp = max;
      a[i] = 0;
      cout << *max_element(a + 0, a + n) << " ";
      a[i] = temp;
    }
  }
  cout << '\n';
  return 0;
}
