#C9982. Maximum Contiguous Books Shelf

    ID: 54135 Type: Default 1000ms 256MiB

Maximum Contiguous Books Shelf

Maximum Contiguous Books Shelf

You are given a sequence of n books with the number of pages in each book provided in an array pages and a positive integer k. Your task is to determine the maximum number of contiguous books that Peter can place on a shelf such that the sum of their pages is divisible by k. More formally, find the maximum length L for which there exists indices i and j (with 0 ≤ i ≤ j < n) satisfying:

x=ijpages[x]0(modk)\sum_{x=i}^{j} pages[x] \equiv 0 \pmod{k}

If no such contiguous segment exists, output 0.

inputFormat

The first line of input contains two space-separated integers n and k, where n is the number of books and k is the divisor.

The second line contains n space-separated integers representing the number of pages in each book.

outputFormat

Output a single integer, the maximum number of contiguous books such that the sum of their pages is divisible by k.

## sample
5 3
4 3 6 3 4
3

</p>