#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tos(T a) {
  stringstream ss;
  string ret;
  ss << a;
  ss >> ret;
  return ret;
}
int n, a;
vector<int> arr;
int main() {
  while (cin >> n) {
    arr.clear();
    for (int(i) = (0); (i) < (n); (i)++) {
      cin >> a;
      arr.push_back(a);
    }
    int boro = *max_element((arr).begin(), (arr).end());
    if (boro == 1) {
      sort(arr.begin(), arr.end());
      arr[arr.size() - 1] = 2;
    } else {
      for (int(i) = (0); (i) < (n); (i)++) {
        if (arr[i] == boro) {
          arr[i] = 1;
          break;
        }
      }
      sort(arr.begin(), arr.end());
    }
    for (int(i) = (0); (i) < (n); (i)++) {
      if (i) cout << " ";
      cout << arr[i];
    }
    cout << endl;
  }
  return 0;
}
