#include <bits/stdc++.h>
int num[100010];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int m = num[0], x = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &num[i]);
      if (num[i] > m) {
        m = num[i];
        x = i;
      }
    }
    if (num[x] != 1)
      num[x] = 1;
    else
      num[x] = 2;
    std::sort(num, num + n);
    for (int i = 0; i < n - 1; i++) printf("%d ", num[i]);
    printf("%d\n", num[n - 1]);
  }
  return 0;
}
