#include <bits/stdc++.h>
using namespace std;
long long int f[100100];
int main() {
  int i, n;
  while (cin >> n) {
    int i1, _max = 0;
    for (i = 0; i < n; i++) {
      cin >> f[i];
      if (f[i] > _max) {
        _max = f[i];
        i1 = i;
      }
    }
    if (n == 1) {
      if (f[0] > 1)
        cout << '1' << endl;
      else
        cout << '2' << endl;
      continue;
    }
    if (_max == 1)
      f[i1] = 2;
    else
      f[i1] = 1;
    sort(f, f + n);
    for (i = 0; i < n - 1; i++) cout << f[i] << ' ';
    cout << f[n - 1] << endl;
  }
  return 0;
}
