Professor Bajtych studies arithmetic sequences modulo an arbitrary integer N. For an integer a, its order modulo n is the smallest integer m>0 such that a⋅m is divisible by n; equivalently, m=n/gcd(a,n).
Bajtych secretly fixes a sequence of k integers a1,a2,…,ak together with a modulus n, but reveals to you only the order mi of each ai modulo n. You may then request a sequence of operations (at most 2k of them). A single operation picks a contiguous range and a constant c, and multiplies every element al,al+1,…,ar in that range by c. After all of your operations are applied, Bajtych pays you an amount, in B$, equal to the order of the sum a1+a2+⋯+ak modulo n.
Bajtych is greedy. He commits to the modulus n and to the concrete values a1,…,ak only after he has seen every operation you requested, and he always chooses them (consistent with the announced orders mi) so as to pay you as little as possible.
Determine the largest payment you can guarantee for yourself, no matter how Bajtych later chooses n and the values ai.
The first line contains a single integer k (1≤k≤100).
The second line contains k integers m1,m2,…,mk (1≤mi<264), where mi is the order of ai modulo n.
Print a single integer: the largest payment, in B$, that you can guarantee regardless of how Bajtych later chooses the modulus n and the values ai 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.