#include <bits/stdc++.h>
using namespace std;
int a[200000];
int i, n;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  int maxi = 0, k = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] > maxi && a[i] != 1) {
      maxi = a[i];
      k = i;
    }
  }
  if (k == 0)
    a[1] = 2;
  else
    a[k] = 1;
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++) printf("%d ", a[i]);
}
