#include <bits/stdc++.h>
using namespace std;
int main() {
  long int x, gr = 0, in, t1;
  cin >> x;
  vector<long int> input;
  for (int i = 0; i < x; i++) {
    cin >> t1;
    input.push_back(t1);
    if (t1 > gr) {
      gr = t1;
      in = i;
    }
  }
  if (gr == 1)
    input[in] = 2;
  else
    input[in] = 1;
  multiset<long int> fset;
  multiset<long int>::iterator it;
  for (int i = 0; i < x; i++) fset.insert(input[i]);
  it = fset.begin();
  for (int i = 0; i < x; i++) {
    cout << *it << ' ';
    it++;
  }
  return 0;
}
