#include <bits/stdc++.h>
using namespace std;
long i, j, n, k, xl, yl, res, z, gg, Min = 2000000000;
vector<long> a;
vector<long> t(400000);
double r = 0;
string s, x, y;
char c;
void build(long v, long tl, long tr) {
  long tm;
  if (tl == tr)
    t[v] = a[tl];
  else {
    tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
  return;
}
long sum(long v, long tl, long tr, long l, long r) {
  long tm;
  if (l > r) return 0;
  if (tl == l && tr == r)
    return t[v];
  else {
    tm = (tl + tr) / 2;
    return sum(v * 2, tl, tm, l, min(tm, r)) +
           sum(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r);
  }
}
void update(long v, long tl, long tr, long pos, long x) {
  long tm;
  if (tl == tr)
    t[v] = x;
  else {
    tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, x);
    else
      update(v * 2 + 1, tm + 1, tr, pos, x);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
int main() {
  scanf("%ld", &n);
  if (n == 1) {
    cin >> n;
    if (n > 1)
      cout << 1;
    else
      cout << 2;
    return 0;
  }
  a.push_back(1);
  for (i = 0; i < n; i++) {
    scanf("%ld", &k);
    if (k < Min) Min = k;
    a.push_back(k);
  }
  sort(a.begin(), a.end());
  a.push_back(2000000000);
  for (i = 1; i <= n; i++) {
    if (i == 1) {
      cout << 1 << " ";
    } else if (i == n) {
      if (Min == 1 && a[i] == Min)
        cout << a[i] + 1 << " ";
      else if (Min == 1000000000)
        cout << a[i] << " ";
      else
        cout << a[i - 1] << " ";
    } else if (a[i - 1] == a[i] && i != 1) {
      if (Min != a[i] || Min > 1)
        cout << a[i] << " ";
      else
        cout << a[i - 1] << " ";
    } else {
      cout << a[i - 1] << " ";
    }
  }
  return 0;
}
