#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, max_index = 0;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > a[max_index]) max_index = i;
  }
  if (a[max_index] != 1)
    a[max_index] = 1;
  else
    a[max_index] = 2;
  sort(a, a + n);
  for (i = 0; i < n; i++) cout << a[i] << " ";
}
