#include <bits/stdc++.h>
using namespace std;
int n, i, max_num, a[100000], pos;
int main() {
  while (cin >> n) {
    for (pos = max_num = i = 0; i < n; ++i) {
      cin >> a[i];
      if (max_num < a[i]) {
        max_num = a[i];
        pos = i;
      }
    }
    a[pos] = (max_num == 1 ? 2 : 1);
    sort(a, a + n);
    for (i = 0; i < n; ++i) cout << a[i] << " ";
    cout << endl;
  }
}
