#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long pwr(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (b * a) / gcd(a, b); }
long long fact(long long n) {
  if (n <= 1) return 1;
  return n * fact(n - 1);
}
long long nPr(long long n, long long r) { return fact(n) / fact(n - r); }
long long d = 0, k = 0;
long long check(string s) {
  long long dd = 0, kk = 0, c = 0;
  for (long long j = 0; j < s.length(); j++) {
    if (s[j] == 'D')
      dd++;
    else
      kk++;
    if (dd * k == kk * d) {
      c++;
      dd = 0, kk = 0;
    }
  }
  return c;
}
void c_p_c() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  c_p_c();
  long long tt;
  tt = 1;
  while (tt-- > 0) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    long long m = 0, mi = 0;
    for (long long j = 0; j < n; j++) {
      cin >> a[j];
      if (m < a[j]) {
        m = a[j];
        mi = j;
      }
    }
    a[mi] = 1;
    if (m == 1) a[mi] = 2;
    set<pair<long long, long long> > s;
    for (long long j = 0; j < n; j++) s.insert({a[j], j});
    for (auto it : s) cout << it.first << " ";
    cout << endl;
  }
  return 0;
}
