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