#include <bits/stdc++.h>
using namespace std;
struct node {
  int num;
} a[100005];
int n;
bool cmp(node a, node b) { return a.num < b.num; }
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i].num);
    sort(a + 1, a + 1 + n, cmp);
    if (a[n].num == 1)
      a[n].num = 2;
    else
      a[n].num = 1;
    sort(a + 1, a + 1 + n, cmp);
    printf("%d", a[1].num);
    for (int i = 2; i <= n; i++) printf(" %d", a[i].num);
    printf("\n");
  }
  return 0;
}
