#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100000], max = 0;
  cin >> n;
  for (int i = 0; i != n; i++) {
    cin >> a[i];
    if (a[i] > a[max]) max = i;
  }
  if (a[max] != 1)
    a[max] = 1;
  else
    a[max] = 2;
  sort(a, a + n);
  for (int i = 0; i != n; i++) cout << a[i] << ' ';
}
