#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18;
const long double eps = 1e-7;
const long double eps1 = 1e-10;
const int mod = (1e9 + 7);
const long long mod1 = 1e9 + 7;
const long long mod2 = 1e9 + 9;
const long long p1 = 29;
const long long p2 = 31;
const int ver1 = (62 * 62);
int ar[100500];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  sort(ar, ar + n);
  if (n != 1 || ar[0] != 1)
    cout << 1 << ' ';
  else {
    cout << 2 << ' ';
  }
  if (n == 1) {
    return 0;
  }
  for (int i = 1; i < n - 1; ++i) {
    cout << ar[i - 1] << ' ';
  }
  if (ar[n - 1] == ar[0] && ar[0] == 1) {
    cout << 2;
  } else {
    cout << ar[n - 2];
  }
  return 0;
}
