#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void pp(T... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
template <typename... T>
void po(T... args) {
  ((cout << args << " "), ...);
  cout << "";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int test = 1;
  for (int tt = 1; tt <= test; tt++) {
    long long int n;
    cin >> n;
    long long int a[n + 1];
    a[0] = 1;
    for (long long int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a, a + n + 1);
    long long int cnt = 0;
    for (long long int i = 1; i <= n; i++) {
      if (a[i] == a[i - 1]) {
        if (a[i] == 1)
          cnt++;
        else
          cnt = 0;
      } else
        cnt = 0;
      if (i != n)
        po(a[i - 1]);
      else if (cnt > 0)
        po(2);
      else
        po(a[i - 1]);
    }
  }
  return 0;
}
