#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int mx = 1e5 + 6;
int a[mx];
int main() {
  int n;
  cin >> n;
  int Mx = 0;
  int Mxp = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (Mx < a[i]) {
      Mx = a[i];
      Mxp = i;
    }
  }
  if (Mx != 1)
    a[Mxp] = 1;
  else
    a[Mxp] = 2;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
