#ABC473E. K 倍子数组 / K-Divisible Subarrays

K 倍子数组 / K-Divisible Subarrays

Problem Statement

You are given a sequence of length NN consisting of non-negative integers: A=(A1,A2,,AN)A=(A _ 1,A _ 2,\ldots,A _ N).

Define the score of a sequence of length 11 or more consisting of sequences of non-negative integers, S=(S1,S2,,Sk)S=(S _ 1,S _ 2,\ldots,S _ k), as the number of sequences Si (1ik)S _ i\ (1\le i\le k) whose sum of elements is divisible by KK.

Find the maximum possible score of a sequence of non-negative integer sequences obtained by dividing AA into one or more contiguous subsequences. Here, dividing a sequence AA of length NN into one or more contiguous subsequences means choosing a sequence of integers $l=(l _ 1,l _ 2,\ldots,l _ k)\ (1=l _ 1\lt l _ 2\lt\cdots\lt l _ k\le N)$ of length 11 or more, and forming the following kk sequences.

  • $(A _ {l _ i},A _ {l _ i+1},\ldots,A _ {l _ {i+1}-1})\ (1\le i\le k)$ (Here, let lk+1=N+1l _ {k+1}=N+1.)

Constraints

  • 1N2×1051\le N\le2\times10 ^ 5
  • 1K1091\le K\le10 ^ 9
  • 0Ai<K0\le A _ i\lt K
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN KK
  • A1A _ 1 A2A _ 2 \ldots ANA _ N

Output

Output the answer.

6 10
6 8 2 2 6 4
2

For example, AA can be divided into four contiguous subsequences as (6),(8,2),(2),(6,4)(6),(8,2),(2),(6,4). The sums of the elements of the second and fourth sequences are multiples of 1010, so the score of ((6),(8,2),(2),(6,4))((6),(8,2),(2),(6,4)) is 22.

AA cannot be divided so that the score is 33 or more, so output 2.

8 1
0 0 0 0 0 0 0 0
8
30 8
5 0 4 2 7 3 2 3 2 4 0 1 4 0 4 1 7 5 2 5 0 3 6 6 2 3 2 2 4 2
8