#include <bits/stdc++.h>
long a[100009];
void qs(long left, long right) {
  long i, j, mid, tam;
  mid = a[left + (rand() % (right - left + 1))];
  i = left;
  j = right;
  while (i <= j) {
    while (a[i] < mid) i++;
    while (a[j] > mid) j--;
    if (i <= j) {
      if (i < j) {
        tam = a[i];
        a[i] = a[j];
        a[j] = tam;
      }
      i++;
      j--;
    }
  }
  if (left < j) qs(left, j);
  if (i < right) qs(i, right);
}
int main() {
  long n, max, i;
  scanf("%d", &n);
  if (!n) return 0;
  scanf("%d", &a[1]);
  max = 1;
  for (i = 2; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > a[max]) max = i;
  }
  if (a[max] == 1)
    a[max] = 2;
  else
    a[max] = 1;
  qs(1, n);
  for (i = 1; i <= n - 1; i++) printf("%d ", a[i]);
  printf("%d", a[n]);
  return 0;
}
