Codeforces Round 512 (Div. 1, based on Technocup 2019 Elimination Round 1)
D
Linear Congruential Generator
Codeforces
未评级
原题
← CE →
翻译中…

You are given a tuple generator 𝑓(𝑘)=(𝑓(𝑘)1,𝑓(𝑘)2,…,𝑓(𝑘)𝑛)f(k)=(f1(k),f2(k),…,fn(k)), where 𝑓(𝑘)𝑖=(𝑎𝑖⋅𝑓(𝑘−1)𝑖+𝑏𝑖)mod𝑝𝑖fi(k)=(ai⋅fi(k−1)+bi)modpi and 𝑓(0)=(𝑥1,𝑥2,…,𝑥𝑛)f(0)=(x1,x2,…,xn). Here 𝑥mod𝑦xmody denotes the remainder of 𝑥x when divided by 𝑦y. All 𝑝𝑖pi are primes.

翻译中…

One can see that with fixed sequences 𝑥𝑖xi, 𝑦𝑖yi, 𝑎𝑖ai the tuples 𝑓(𝑘)f(k) starting from some index will repeat tuples with smaller indices. Calculate the maximum number of different tuples (from all 𝑓(𝑘)f(k) for 𝑘≥0k≥0) that can be produced by this generator, if 𝑥𝑖xi, 𝑎𝑖ai, 𝑏𝑖bi are integers in the range [0,𝑝𝑖−1][0,pi−1] and can be chosen arbitrary. The answer can be large, so print the remainder it gives when divided by 109+7109+7

翻译中…

Input

翻译中…

The first line contains one integer 𝑛n (1≤𝑛≤2⋅1051≤n≤2⋅105) — the number of elements in the tuple.

翻译中…

The second line contains 𝑛n space separated prime numbers — the modules 𝑝1,𝑝2,…,𝑝𝑛p1,p2,…,pn (2≤𝑝𝑖≤2⋅1062≤pi≤2⋅106).

翻译中…

Output

翻译中…

Print one integer — the maximum number of different tuples modulo 109+7109+7.

翻译中…

Note

翻译中…

In the first example we can choose next parameters: 𝑎=[1,1,1,1]a=[1,1,1,1], 𝑏=[1,1,1,1]b=[1,1,1,1], 𝑥=[0,0,0,0]x=[0,0,0,0], then 𝑓(𝑘)𝑖=𝑘mod𝑝𝑖fi(k)=kmodpi.

翻译中…

In the second example we can choose next parameters: 𝑎=[1,1,2]a=[1,1,2], 𝑏=[1,1,0]b=[1,1,0], 𝑥=[0,0,1]x=[0,0,1].

翻译中…

样例

Input #1
4
2 3 5 7
Output #1
210
InputCopy OutputCopy
Input #2
3
5 3 3
Output #2
30
InputCopy OutputCopy
题目信息
题号
1053D
时间限制
2 s
内存限制
512 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。