#include <bits/stdc++.h>
using namespace std;
int tr[600005];
int a[100005], b[100005];
bool chk[150005];
vector<int> pr[2];
bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }
int Set(int N, int pos) { return N = N | (1 << pos); }
int status[(2000000 / 32) + 2];
queue<int> q;
void sieve(int N, int n) {
  int i, j, sqrtN;
  sqrtN = int(sqrt(N));
  for (i = 3; i <= sqrtN; i += 2) {
    if (Check(status[i >> 5], i & 31) == 0) {
      for (j = i * i; j <= N; j += (i << 1)) {
        status[j >> 5] = Set(status[j >> 5], j & 31);
      }
    }
  }
  pr[1].push_back(2);
  pr[0].push_back(2);
  for (i = 3; i <= N; i += 2) {
    if (Check(status[i >> 5], i & 31) == 0) {
      pr[1].push_back(i);
      if (i <= n) pr[0].push_back(i);
    }
  }
}
int bs(int n, int l, int r) {
  int m;
  while (l < r) {
    m = (l + r) >> 1;
    if (pr[1][m] == n)
      return m;
    else if (pr[1][m] > n)
      r = m;
    else
      l = m + 1;
  }
  if (pr[1][l] >= n)
    return l;
  else
    return l + 1;
}
void init(int n, int b, int e) {
  if (b == e) {
    tr[n] = b;
    return;
  }
  int l, r, m;
  l = (n << 1) + 1;
  r = l + 1;
  m = (b + e) >> 1;
  init(l, b, m);
  init(r, m + 1, e);
  tr[n] = min(tr[l], tr[r]);
}
int get(int n, int b, int e, int i, int j) {
  if (b > j || i > e) return 10000000;
  if (i <= b && j >= e) return tr[n];
  int l, r, m;
  l = (n << 1) + 1;
  r = l + 1;
  m = (b + e) >> 1;
  return min(get(l, b, m, i, j), get(r, m + 1, e, i, j));
}
void update(int n, int b, int e, int i, int val) {
  if (i < b || i > e) return;
  if (b == e) {
    tr[n] = val;
    return;
  }
  int l, r, m;
  l = (n << 1) + 1;
  r = l + 1;
  m = (b + e) >> 1;
  update(l, b, m, i, val);
  update(r, m + 1, e, i, val);
  tr[n] = min(tr[l], tr[r]);
}
int main() {
  sieve(2000000, sqrt(100000) + 2);
  int s = pr[1].size();
  int n, ii, cc;
  init(0, 0, s - 1);
  scanf("%d", &n);
  bool bb = 0;
  for (int i = 0; i < n; i = i + 1) {
    scanf("%d", &a[i]);
    if (bb) {
      ii = get(0, 0, s - 1, 0, s - 1);
      b[i] = pr[1][ii];
      update(0, 0, s - 1, ii, s + 5);
      continue;
    }
    b[i] = a[i];
    for (int j = 0; j < pr[0].size(); j = j + 1) {
      if (a[i] <= 1) break;
      if (a[i] % pr[0][j] == 0) {
        if (!chk[j]) {
          q.push(j);
          while (a[i] % pr[0][j] == 0) a[i] /= pr[0][j];
        } else {
          while (!q.empty()) q.pop();
          while (1) {
            b[i]++;
            a[i] = b[i];
            bb = 1;
            for (int j = 0; j < pr[1].size(); j = j + 1) {
              if (a[i] <= 1) break;
              if (a[i] % pr[1][j] == 0) {
                if (!chk[j]) {
                  q.push(j);
                  while (a[i] % pr[1][j] == 0) a[i] /= pr[1][j];
                } else {
                  bb = 0;
                  break;
                }
              }
            }
            if (bb) {
              while (!q.empty()) {
                ii = q.front();
                q.pop();
                chk[ii] = 1;
                update(0, 0, s - 1, ii, s + 5);
              }
              break;
            } else {
              while (!q.empty()) q.pop();
            }
          }
        }
      }
    }
    if (a[i] > 1 && bb == 0) {
      ii = bs(a[i], 0, s - 1);
      q.push(ii);
      if (chk[ii]) {
        while (!q.empty()) q.pop();
        while (1) {
          b[i]++;
          a[i] = b[i];
          bb = 1;
          for (int j = 0; j < pr[1].size(); j = j + 1) {
            if (a[i] <= 1) break;
            if (a[i] % pr[1][j] == 0) {
              if (!chk[j]) {
                q.push(j);
                while (a[i] % pr[1][j] == 0) a[i] /= pr[1][j];
              } else {
                bb = 0;
                break;
              }
            }
          }
          if (bb) {
            while (!q.empty()) {
              ii = q.front();
              q.pop();
              chk[ii] = 1;
              update(0, 0, s - 1, ii, s + 5);
            }
            break;
          } else {
            while (!q.empty()) q.pop();
          }
        }
      }
    }
    if (bb == 0) {
      while (!q.empty()) {
        ii = q.front();
        q.pop();
        chk[ii] = 1;
        update(0, 0, s - 1, ii, s + 5);
      }
    } else {
      while (!q.empty()) q.pop();
    }
  }
  for (int i = 0; i < n; i = i + 1) printf("%d ", b[i]);
  return 0;
}
