#include <bits/stdc++.h>
using namespace std;
long long i, b, j, k, q, c, n, m;
vector<long long> a;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  {
    cin >> n;
    for (i = 0; i < n; i++) cin >> j, a.push_back(j);
    sort(a.begin(), a.end());
    auto it = a.end();
    it--;
    for (i = 1; i < 100000000l; i++) {
      if (*it != i) {
        *it = i;
        break;
      }
    }
    sort(a.begin(), a.end());
    for (auto it : a) cout << it << " ";
    cout << "\n";
  }
  return 0;
}
