<?php
 
function input_and_explode() {
    $input_line = trim(fgets(STDIN));
    return explode(" ", $input_line);
}

list($N, $M) = input_and_explode();

$A = input_and_explode();

$result = 0;

for ($r = 1; $r <= $N; $r++) {
    for ($l = 1; $l <= $r; $l++) {
        $A_sliced = array_slice($A, $l - 1, $r - $l + 1);
        $A_sliced_sum = array_sum($A_sliced);
        if ($A_sliced_sum % $M === 0) {
            $result++;
        }
    }
}

echo "$result\n";