#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) cin >> a[i];
  sort(a.begin(), a.end());
  vector<int> b(n);
  b[0] = 1;
  for (int(i) = (int)(1); (i) < (int)(n); ++(i)) b[i] = min(a[i - 1], a[i]);
  if (b[n - 1] == 1 && a[n - 1] == 1) b[n - 1] = 2;
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) cout << b[i] << " ";
  return 0;
}
