Олимпиадный тренинг

Задача 39473. Number of subsequences


Задача

Темы: ЕГЭ Циклы
Given a sequence of N natural numbers. All its continuous subsequences starting from the first element of the sequence are considered. Find the number of subsequences whose sum is a multiple of K.

Input
The first line contains two numbers: the number of numbers in the sequence N (1 <= N <= 108) and the number ( 1 <= K <= 100). Next comes N lines, one natural number per line. Each number does not exceed 10000.

Imprint
Display the answer to the problem
 
 
Examples
# Input Output
1 5 3
33
41
19
22
40
2