#include <bits/stdc++.h>
using namespace std;
int n, mx = 0, pos;
vector<int> arr(1e5 + 5);
int main(void) {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    if (arr[i] > mx) {
      mx = arr[i];
      pos = i;
    }
  }
  if (mx == 1) {
    arr[pos] = 2;
  } else {
    arr[pos] = 1;
  }
  sort(arr.begin() + 1, arr.begin() + n + 1);
  for (int i = 1; i <= n; ++i) {
    cout << arr[i] << " \n"[i == n];
  }
  return 0;
}
