#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> v(n);
    int maxim = 0, pos = -1;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] > maxim) {
        maxim = v[i];
        pos = i;
      }
    }
    if (maxim == 1)
      v[pos] = 2;
    else
      v[pos] = 1;
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
      if (i) cout << ' ';
      cout << v[i];
    }
    cout << endl;
  }
}
