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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    long m = nm[1];
    auto a = readints;

    int[long] d = [0: 1];
    long sum = 0;
    long ans = 0;
    for (int i = 0; i < a.length; i++) {
        sum = (sum + a[i]) % m;
        ans += d.get(sum, 0);
        d[sum]++;
    }
    writeln(ans);
}
