#K5436. Contiguous Subsequence Divisibility

    ID: 29736 Type: Default 1000ms 256MiB

Contiguous Subsequence Divisibility

Contiguous Subsequence Divisibility

Given an integer sequence a1,a2,,ana_1, a_2, \ldots, a_n and an integer kk, determine whether there exists a contiguous subsequence (i.e. a subarray) whose sum is divisible by kk. Formally, find if there exist indices ii and jj with 1ijn1 \le i \le j \le n such that $$\sum_{t=i}^{j}a_t \equiv 0 \pmod{k}.$$

The input will contain the length of the sequence, the modulus kk, and the nn integers in the sequence. If such a subsequence exists, output YES; otherwise, output NO.

inputFormat

The input is given via standard input (stdin).

The first line contains two integers nn and kk, where nn is the number of integers in the sequence and kk is the divisor.
The second line contains nn space-separated integers representing the sequence.

outputFormat

Output a single line to standard output (stdout):

If there exists a contiguous subsequence whose sum is divisible by kk, print YES. Otherwise, print NO.## sample

5 3
1 2 3 4 5
YES