import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const N = tmp[0], M = tmp[1];
    auto as = readln.split.to!(long[]);
    as = 0 ~ as;
    foreach (i; 0..N) as[i+1] += as[i];
    long cnt = 0;
    foreach (l; 0..N) {
        foreach (r; l..N) {
            if ((as[r+1] - as[l]) % M == 0) cnt++;
        }
    }
    writeln(cnt);
}

