#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
int num[maxn], n, m, ans, cnt;
int cmp(int a, int b) { return a < b; }
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &num[i]);
    }
    sort(num, num + n, cmp);
    if (num[n - 1] != 1)
      num[n - 1] = 1;
    else
      num[n - 1] = 2;
    sort(num, num + n, cmp);
    for (int i = 0; i < n; i++) {
      printf("%d ", num[i]);
    }
    printf("\n");
  }
  return 0;
}
