#B4004. Divisibility in a Sequence
Divisibility in a Sequence
Divisibility in a Sequence
Given a sequence of n positive integers \(A = [a_1,a_2,\dots,a_n]\), determine if there exists an index \(i\) (where \(1 \le i \le n\)) such that \(a_i\) is a multiple of every element in \(A\). In other words, check whether there exists an element \(a_i\) satisfying \(a_i \mod a_j = 0\) for every \(j\) from 1 to \(n\).
inputFormat
The input consists of two lines. The first line contains a single integer \(n\), the number of elements in the sequence. The second line contains \(n\) space-separated positive integers representing the sequence \(A\).
outputFormat
Output a single line containing "YES" if there exists an element in \(A\) that is a multiple of every element in \(A\); otherwise, output "NO".
sample
3
3 6 24
YES