#include <bits/stdc++.h>
using namespace std;
vector<int> f;
int main() {
  int n;
  cin >> n;
  int max = -1;
  int maxindex = -1;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    if (temp > max) {
      max = temp;
      maxindex = i;
    }
    f.push_back(temp);
  }
  for (int i = 1; i <= 1e9 + 1; i++) {
    if (f[maxindex] != i) {
      f[maxindex] = i;
      break;
    }
  }
  sort(f.begin(), f.end());
  for (int i = 0; i < n; i++) {
    cout << f[i];
    if (i != n - 1) cout << " ";
  }
  return 0;
}
