#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long int> v;
  long long int n, num, max_ind = 0, max_num = -1;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> num;
    v.push_back(num);
    if (num > max_num) {
      max_num = num;
      max_ind = i;
    }
  }
  if (max_num != 1)
    v[max_ind] = 1;
  else
    v[max_ind] = 2;
  sort(v.begin(), v.end());
  for (long long int i = 0; i < n; i++) {
    cout << v[i] << " ";
  }
  return 0;
}
