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