<?php

fscanf(STDIN, "%d %d", $n, $m);
$boxes = explode(' ', trim(fgets(STDIN)));
$counter = 0;

foreach ($boxes as $idx => $box) {
    $boxes[$idx] = $box % $m;
}
foreach ($boxes as $idx => $box) {
    $sum = 0;
    for ($i = $idx; $i < $n; $i++) {
        $sum += $boxes[$i];
        if ($sum % $m === 0) {
            $counter++;
        }
    }
}

echo $counter;