#include <bits/stdc++.h>
using namespace std;
inline int sqr(int x) { return x * x; }
inline int cube(int x) { return x * x * x; }
inline long long sqrLL(long long x) { return x * x; }
inline long long cubeLL(long long x) { return x * x * x; }
const long long LLINF = 9223372036854775807LL;
const long long LLINF17 = 100000000000000000LL;
const int INF = 1000000000;
const int INF9 = 1000000000;
long long MOD = 1000000009;
const double eps = 1e-7;
const double PI = acos(-1.0);
template <typename T>
void check(T &a, const T &b) {
  if (a >= b) {
    a %= b;
  }
}
template <typename T>
void read(T &x) {
  register T c = getchar();
  x = 0;
  int t = 0;
  if (c == '-') t = 1, c = getchar();
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (t) x = -x;
}
template <typename T>
T gcd(T u, T v) {
  if (u == v) return u;
  if (u == 0) return v;
  if (v == 0) return u;
  if (~u & 1) {
    if (v & 1)
      return gcd(u >> 1, v);
    else
      return gcd(u >> 1, v >> 1) << 1;
  }
  if (~v & 1) return gcd(u, v >> 1);
  if (u > v) return gcd((u - v) >> 1, v);
  return gcd((v - u) >> 1, u);
}
long long mulmod(long long a, long long b, long long m) {
  long long q = (long long)(((long double)a * (long double)b) / (long double)m);
  long long r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T, typename S>
T expo(T e, S n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T powerL(T e, T n, T &m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mulmod(x, p, m);
    p = mulmod(p, p, m);
    n >>= 1;
  }
  return x;
}
template <typename T>
T InverseEuler(T a, T &m) {
  return (a == 1 ? 1 : power(a, m - 2, m));
}
int main() {
  int n, count_rest = 0;
  bool t = 0;
  read(n);
  vector<int> v, _v;
  _v.push_back(1);
  for (int(i) = (0); (i) < (n); (i)++) {
    int a;
    read(a);
    v.push_back(a);
  }
  if (n == 1) {
    if (v[0] == 1) {
      cout << 2 << "\n";
    } else {
      cout << 1 << "\n";
    }
    return 0;
  }
  sort(v.begin(), v.end());
  for (int i = n - 1; i >= 1; i--) {
    if (v[i] != 1) {
      _v.push_back(v[i - 1]);
    } else if (v[i] == 1) {
      if (!t) {
        count_rest = n - 1 - i;
        t = 1;
      }
      if (count_rest >= 1) {
        _v.push_back(1);
      } else {
        _v.push_back(2);
        count_rest = 2;
      }
    }
  }
  sort(_v.begin(), _v.end());
  for (int i : _v) {
    cout << i << " ";
  }
  return 0;
}
