#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
map<long long, long long> m, m1;
void seive(long long n) {
  bool prime[n + 1];
  memset(prime, true, n + 1);
  long long i, j, p;
  prime[0] = false;
  prime[1] = false;
  for (p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (i = 0; i <= n; i++) {
    if (prime[i] == true) {
      v.push_back(i);
      m[i] = 1;
    }
  }
}
int spf[1000001];
void sieve2() {
  spf[1] = 1;
  for (int i = 2; i < 1000001; i++) spf[i] = i;
  for (int i = 4; i < 1000001; i += 2) spf[i] = 2;
  for (int i = 3; i * i < 1000001; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < 1000001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
vector<long long> getFactorization(long long x) {
  vector<long long> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
int main() {
  seive(1500000);
  sieve2();
  long long n;
  cin >> n;
  vector<long long>::iterator ip;
  long long i, j, k, l = 0, o = 0;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    vector<long long> p = getFactorization(a[i]);
    ip = std::unique(p.begin(), p.begin() + p.size());
    p.resize(std::distance(p.begin(), ip));
    for (j = 0; j < p.size(); j++) {
      m1[p[j]]++;
      if (m1[p[j]] > 1 && l == 0) {
        l = 2;
        o = i;
      }
    }
    if (l == 0) {
      for (j = 0; j < p.size(); j++) {
        m[p[j]]--;
      }
    }
  }
  if (l == 0) {
    for (i = 0; i < n; i++) cout << a[i] << " ";
    return 0;
  }
  for (i = 0; i < o; i++) {
    cout << a[i] << " ";
  }
  long long t = n - o - 1;
  for (j = 0; j < v.size(); j++) {
    if (v[j] > a[o] && m[v[j]] > 0) {
      break;
    }
  }
  long long take = 0, ram = v[j];
  for (i = a[o]; i < ram; i++) {
    take = 0;
    vector<long long> p = getFactorization(i);
    ip = std::unique(p.begin(), p.begin() + p.size());
    p.resize(std::distance(p.begin(), ip));
    for (j = 0; j < p.size(); j++) {
      if (m[p[j]] <= 0) {
        take = 1;
      }
    }
    if (take == 0) {
      for (j = 0; j < p.size(); j++) {
        m[p[j]]--;
      }
      break;
    }
  }
  cout << i << " ";
  m[i]--;
  j = 0;
  while (t > 0) {
    if (m[v[j]] > 0) {
      cout << v[j] << " ";
      m[v[j]]--;
      t--;
    }
    j++;
  }
}
