{"problem":{"name":"D. Mahmoud and Ehab and another array construction task","description":{"content":"Mahmoud has an array _a_ consisting of _n_ integers. He asked Ehab to find another array _b_ **of the same length** such that: *   _b_ is lexicographically greater than or equal to _a_. *   _b__i_ ≥ ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF959D"},"statements":[{"statement_type":"Markdown","content":"Mahmoud has an array _a_ consisting of _n_ integers. He asked Ehab to find another array _b_ **of the same length** such that:\n\n*   _b_ is lexicographically greater than or equal to _a_.\n*   _b__i_ ≥ 2.\n*   _b_ is pairwise coprime: for every 1 ≤ _i_ < _j_ ≤ _n_, _b__i_ and _b__j_ are coprime, i. e. _GCD_(_b__i_, _b__j_) = 1, where _GCD_(_w_, _z_) is the greatest common divisor of _w_ and _z_.\n\nEhab wants to choose a special array so he wants the lexicographically minimal array between all the variants. Can you find it?\n\nAn array _x_ is lexicographically greater than an array _y_ if there exists an index _i_ such than _x__i_ > _y__i_ and _x__j_ = _y__j_ for all 1 ≤ _j_ < _i_. An array _x_ is equal to an array _y_ if _x__i_ = _y__i_ for all 1 ≤ _i_ ≤ _n_.\n\n## Input\n\nThe first line contains an integer _n_ (1 ≤ _n_ ≤ 105), the number of elements in _a_ and _b_.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_ (2 ≤ _a__i_ ≤ 105), the elements of _a_.\n\n## Output\n\nOutput _n_ space-separated integers, the _i_\\-th of them representing _b__i_.\n\n[samples]\n\n## Note\n\nNote that in the second sample, the array is already pairwise coprime so we printed it.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Mahmoud 有一个由 #cf_span[n] 个整数组成的数组 #cf_span[a]。他要求 Ehab 找到另一个 *长度相同* 的数组 #cf_span[b]，使得：\n\nEhab 想要选择一个特殊的数组，因此他希望在所有可能的变体中找到字典序最小的数组。你能找到它吗？\n\n数组 #cf_span[x] 被称为字典序大于数组 #cf_span[y]，如果存在一个下标 #cf_span[i]，使得 #cf_span[xi > yi] 且对所有 #cf_span[1 ≤ j < i] 都有 #cf_span[xj = yj]。数组 #cf_span[x] 等于数组 #cf_span[y]，当且仅当对所有 #cf_span[1 ≤ i ≤ n] 都有 #cf_span[xi = yi]。\n\n第一行包含一个整数 #cf_span[n] #cf_span[(1 ≤ n ≤ 105)]，表示数组 #cf_span[a] 和 #cf_span[b] 的元素个数。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1], #cf_span[a2], #cf_span[...], #cf_span[an] #cf_span[(2 ≤ ai ≤ 105)]，表示数组 #cf_span[a] 的元素。\n\n请输出 #cf_span[n] 个用空格分隔的整数，第 #cf_span[i] 个整数表示 #cf_span[bi]。\n\n注意，在第二个测试用例中，数组已经两两互质，因此直接输出原数组。\n\n## Input\n\n第一行包含一个整数 #cf_span[n] #cf_span[(1 ≤ n ≤ 105)]，表示数组 #cf_span[a] 和 #cf_span[b] 的元素个数。第二行包含 #cf_span[n] 个整数 #cf_span[a1], #cf_span[a2], #cf_span[...], #cf_span[an] #cf_span[(2 ≤ ai ≤ 105)]，表示数组 #cf_span[a] 的元素。\n\n## Output\n\n请输出 #cf_span[n] 个用空格分隔的整数，第 #cf_span[i] 个整数表示 #cf_span[bi]。\n\n[samples]\n\n## Note\n\n注意，在第二个测试用例中，数组已经两两互质，因此直接输出原数组。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the length of the arrays.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be the given array of integers, where $ a_i \\in \\mathbb{Z} $ and $ 2 \\leq a_i \\leq 10^5 $.  \nLet $ B = (b_1, b_2, \\dots, b_n) $ be the target array of integers, with $ b_i \\geq 1 $, satisfying:  \n- $ \\gcd(b_i, b_j) = 1 $ for all $ 1 \\leq i < j \\leq n $ (pairwise coprime),  \n- $ b_i \\geq a_i $ for all $ i \\in \\{1, \\dots, n\\} $.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. $ 2 \\leq a_i \\leq 10^5 $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nFind the lexicographically minimal array $ B = (b_1, \\dots, b_n) $ satisfying the above constraints.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF959D","tags":["constructive algorithms","greedy","math","number theory"],"sample_group":[["5\n2 3 5 4 13","2 3 5 7 11"],["3\n10 3 7","10 3 7"]],"created_at":"2026-03-03 11:00:39"}}