#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b, c, odd, even, sum, t, cnt;
  t = 1;
  while (t--) {
    cin >> n;
    long long int ar[n], cnt = 0;
    for (int i = 0; i < n; i++) {
      cin >> ar[i];
      if (ar[i] == 1) {
        cnt++;
      }
    }
    sort(ar, ar + n);
    ar[n - 1] = 1;
    sort(ar, ar + n);
    if (cnt == n) {
      for (int i = 0; i < n - 1; i++) {
        cout << ar[i] << " ";
      }
      cout << "2" << endl;
    } else {
      for (int i = 0; i < n; i++) {
        cout << ar[i] << " ";
      }
    }
  }
  return 0;
}
