BARMAN

No attempts yetTime limit1sMemory limit128 MB

Problem

Professor Bajtych studies arithmetic sequences modulo an arbitrary integer NN. For an integer aa, its order modulo nn is the smallest integer m>0m > 0 such that ama \cdot m is divisible by nn; equivalently, m=n/gcd(a,n)m = n / \gcd(a, n).

Bajtych secretly fixes a sequence of kk integers a1,a2,,aka_1, a_2, \dots, a_k together with a modulus nn, but reveals to you only the order mim_i of each aia_i modulo nn. You may then request a sequence of operations (at most 2k2k of them). A single operation picks a contiguous range and a constant cc, and multiplies every element al,al+1,,ara_l, a_{l+1}, \dots, a_r in that range by cc. After all of your operations are applied, Bajtych pays you an amount, in B$, equal to the order of the sum a1+a2++aka_1 + a_2 + \dots + a_k modulo nn.

Bajtych is greedy. He commits to the modulus nn and to the concrete values a1,,aka_1, \dots, a_k only after he has seen every operation you requested, and he always chooses them (consistent with the announced orders mim_i) so as to pay you as little as possible.

Determine the largest payment you can guarantee for yourself, no matter how Bajtych later chooses nn and the values aia_i.

Input

The first line contains a single integer kk (1k1001 \le k \le 100).

The second line contains kk integers m1,m2,,mkm_1, m_2, \dots, m_k (1mi<2641 \le m_i < 2^{64}), where mim_i is the order of aia_i modulo nn.

Output

Print a single integer: the largest payment, in B$, that you can guarantee regardless of how Bajtych later chooses the modulus nn and the values aia_i consistent with the given orders.

This value can be extremely large (up to thousands of digits), so compute and print it in full using big-integer arithmetic.