PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000351. Tổng chia hết theo modulo (Modulo Sum)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng chia hết theo modulo (Modulo Sum)

Modulo Sum

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn nonnegative integers a1,a2,…,ana_1,a_2,\ldots,a_n and a positive modulus mm, determine whether one can select at least one distinct index so that the sum of the selected values is divisible by mm. The selected indices form a subsequence and need not be consecutive.

The empty subsequence is forbidden. Each position can be selected at most once; equal values at different indices remain distinct choices.

Input

  • First line: integers n,mn,m.
  • Second line: the nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print YES if such a nonempty subsequence exists; otherwise print NO.

Subtasks

  • Subtask 1 (20 points): 1<=n<=12,2<=m<=20,0<=ai<=1031 <= n <= 12, 2 <= m <= 20, 0 <= a_i <= 10^3.
  • Subtask 2 (30 points): 1<=n<=1000,2<=m<=1000,0<=ai<=1091 <= n <= 1000, 2 <= m <= 1000, 0 <= a_i <= 10^9.
  • Subtask 3 (50 points): 1<=n<=106,2<=m<=1000,0<=ai<=1091 <= n <= 10^6, 2 <= m <= 1000, 0 <= a_i <= 10^9.

Examples

Example 1

Input

3 5
1 2 3

Output

YES

Explanation

Choose values 2 and 3: the sum 5 is divisible by 5.

Example 2

Input

1 6
5

Output

NO

Explanation

The only nonempty subsequence is [5], whose sum leaves remainder 5 modulo 6.

Example 3

Input

4 6
3 1 1 3

Output

YES

Explanation

Choose the first and last elements: 3+3=6; their indices differ.