use strict;

my @lines = <STDIN>;
my ($N, $M) = split(/ /, $lines[0]);
my @A = split(/ /, $lines[1]);
my @S = (0);

for (my $i = 0; $i < $N; $i++) {
    push(@S, $S[$i] + $A[$i]);
}

my $count = 0;
for (my $l = 1; $l <= $N; $l++) {
    for (my $r = $l; $r <= $N; $r++) {
        if (($S[$r] - $S[$l-1]) % $M == 0) {
            $count ++;
        }
    }
}

print $count, "\n";
