#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = (int)1e5 + 20;
int a[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  if (n == 1) {
    cout << (a[1] == 1 ? 2 : 1);
    return 0;
  }
  sort(a + 1, a + n + 1);
  cout << 1 << ' ';
  for (int i = 2; i < n; ++i) cout << a[i - 1] << ' ';
  if (a[n] > a[n - 1])
    cout << a[n - 1];
  else
    cout << (a[n] == 1 ? 2 : a[n]);
  return 0;
}
