#C3660. Transforming Sequence into Identical Elements

    ID: 47112 Type: Default 1000ms 256MiB

Transforming Sequence into Identical Elements

Transforming Sequence into Identical Elements

You are given a sequence of N integers. Your task is to determine whether it is possible to transform the sequence into a sequence with all identical elements by applying a specific allowed operation several times. In this problem, the allowed operation is implicitly defined. The underlying idea is that if all numbers in the sequence share a common divisor greater than 1, they can eventually be made identical by repeatedly dividing them by their greatest common divisor ((\gcd)).

Formally, given a sequence (a_1, a_2, \dots, a_N), find the greatest common divisor (G = \gcd(a_1, a_2, \dots, a_N)). If (G > 1), output "YES" indicating the sequence can be transformed into identical elements; otherwise, output "NO".

Note: For a sequence of all zeros, consider it already transformed (output "YES").

inputFormat

The first line contains a single integer (N), the number of elements in the sequence. The second line contains (N) integers separated by spaces, representing the sequence.

outputFormat

Output a single line containing either "YES" if the sequence can be transformed into identical elements by the allowed operation, or "NO" otherwise.## sample

3
4 8 12
YES

</p>