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[long] cnt;
    foreach (a; as) {
        const key = a % M;
        if (key !in cnt) cnt[key] = 0;
        cnt[key]++;
    }

    cnt.values.map!(c => c * (c-1)/2).sum.writeln;
}

