PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000229. Kiến tạo dãy nguyên tố cùng nhau của Mahmoud và Ehab (Mahmoud and Ehab and another array construction task)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Kiến tạo dãy nguyên tố cùng nhau của Mahmoud và Ehab (Mahmoud and Ehab and another array construction task)

Mahmoud and Ehab and another array construction task

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer array a1,a2,…,ana_1,a_2,\ldots,a_n, construct an array bb of equal length such that:

  • bb is lexicographically greater than or equal to aa: if unequal, the first position at which they differ must have bi>aib_i>a_i.
  • Every bi≥2b_i\ge2.
  • The elements are pairwise coprime: gcd⁡(bi,bj)=1\gcd(b_i,b_j)=1 for every i≠ji\ne j.

Among all valid arrays, output the lexicographically smallest one.

Input

The first line contains nn. The next line contains exactly nn integers a1,…,ana_1,\ldots,a_n.

Output

Print exactly nn space-separated integers b1,…,bnb_1,\ldots,b_n forming the lexicographically smallest array that satisfies all three requirements.

Subtasks

  • Subtask 1 (20 points): 1≤n≤81\le n\le8; 2≤ai≤1052\le a_i\le10^5 for every ii.

  • Subtask 2 (30 points): 1≤n≤20001\le n\le2000; 2≤ai≤1052\le a_i\le10^5 for every ii.

  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 2≤ai≤1052\le a_i\le10^5 for every ii.

Examples

Input

5
2 3 5 4 13

Output

2 3 5 7 11

Explanation

The prefix 2,3,52,3,5 is already pairwise coprime, so it is kept. The next required value is at least 44, but 44 uses prime 22 already present. The smallest available integer not below 44 is 77. At this point bb is strictly lexicographically larger than aa, so b5b_5 need not be at least 1313; the smallest unused prime is 1111. The answer is 2,3,5,7,112,3,5,7,11.