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

#QHD0000072. Tổng chia hết cho mô-đun (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 cho mô-đun (Modulo Sum)

Modulo Sum

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given nn nonnegative integers a1,…,ana_1,\ldots,a_n and an integer m≥2m\ge2. Determine whether there exists a non-empty subsequence of distinct positions whose sum is divisible by mm.

The chosen positions need not be consecutive, but no position may be used twice. Equal values at different positions can both be selected. The empty subsequence is forbidden, even though its sum would be zero. In contrast, selecting a single input value equal to zero is valid.

Print YES if such a subsequence exists; otherwise print NO. For example, from 1,2,31,2,3 and m=5m=5, selecting 22 and 33 gives a divisible sum.

Input

The first line contains n,mn,m. The second line contains nn integers a1,…,ana_1,\ldots,a_n.

Output

Print YES for a non-empty divisible subset, or NO otherwise.

Subtasks

  • Subtask 1 (20 points): 1≤n≤161\le n\le 16; 2≤m≤302\le m\le 30; 0≤ai≤1090\le a_i\le10^9; the chosen subsequence must be non-empty.
  • Subtask 2 (30 points): 1≤n≤2001\le n\le 200; 2≤m≤2002\le m\le 200; 0≤ai≤1090\le a_i\le10^9; the chosen subsequence must be non-empty.
  • Subtask 3 (50 points): 1≤n≤10000001\le n\le 1000000; 2≤m≤10002\le m\le 1000; 0≤ai≤1090\le a_i\le10^9; the chosen subsequence must be non-empty.

Examples

Input

3 5
1 2 3

Output

YES

Explanation

Choose the elements at positions 22 and 33. Their sum 2+3=52+3=5 is divisible by 55.