import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto nm = readln.chomp.split.map!(to!long);
    long n = nm[0];
    long m = nm[1];
    auto A = readln.chomp.split.map!(to!long).array;

    long[long] t;
    t[0] = 1;
    long b;

    foreach (a; A)
    {
        b += a;
        b %= m;
        long mod = b % m;
        if (mod in t)
            t[mod]++;
        else
            t[mod] = 1;
    }
    long result;
    foreach (key, val; t)
    {
        result += (val).c(2);
    }
    writeln(result);
}

long c(long a, long b)
{
    if (a < b)
    {
        return 0;
    }

    long c = 1;
    foreach (i; a - b + 1 .. a + 1)
        c *= i;
    long d = 1;
    foreach (i; 1 .. b + 1)
        d *= i;
    return c / d;
}
