#include <iostream>
#include <map>

using namespace std;

u_int64_t a[100'000];
u_int64_t pSum[100'001];
map<u_int64_t, u_int64_t> eqCount;

int main()
{

    int N;
    u_int64_t M;
    cin >> N >> M;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i <= N; i++)
    {
        if (i == 0)
        {
            pSum[i] = 0;
            continue;
        }

        pSum[i] = pSum[i - 1] + a[i];
        pSum[i] %= M;
    }

    u_int64_t wholeCount = 0;
    for (int i = 0; i <= N; i++)
    {
        wholeCount += eqCount[pSum[i]];
        eqCount[pSum[i]]++;
    }

    cout << wholeCount << endl;
    return 0;
}