#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int cl(int a, int b) { return (a / b) + (a % b != 0); }
void solve() {
  int n;
  cin >> n;
  vector<int> V(n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> V[i];
  }
  for (int i = 1; i < n; i++) {
    if (V[i] > V[mx]) mx = i;
  }
  if (V[mx] == 1)
    V[mx] = 2;
  else
    V[mx] = 1;
  sort((V).begin(), (V).end());
  for (int x : V) cout << x << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  T = 1;
  while (T--) {
    solve();
  }
}
