#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 1, INF = 1e18 + 1, mod = 1e6 + 3;
long long i, j, k, n, m, t, answer, a[maxn];
int main() {
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > m) {
      m = a[i];
      j = i;
    }
  }
  if (a[j] != 1) {
    a[j] = 1;
  } else {
    a[j] = 2;
  }
  sort(a, a + n);
  for (i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
}
