#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
int N, M, A; cin >> N >> M; ll sum = 0, pairs = 0; map< int, int > count;
for( int i = 0; i < N; i++ )
cin >> A, sum += A, sum %= M, count[ sum ]++;
for( auto p: count )
{
ll k = p.second;
if ( p.first == 0 )
k *= k + 1;
else
k *= k - 1;
k >>= 1, pairs += k;
}
cout << pairs;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKIAppbnQgbWFpbigpCnsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oIGZhbHNlICksIGNpbi50aWUoIG51bGxwdHIgKSwgY291dC50aWUoIG51bGxwdHIgKTsKIAogICAgaW50IE4sIE0sIEE7IGNpbiA+PiBOID4+IE07IGxsIHN1bSA9IDAsIHBhaXJzID0gMDsgbWFwPCBpbnQsIGludCA+IGNvdW50OwogCiAgICBmb3IoIGludCBpID0gMDsgaSA8IE47IGkrKyApCiAgICAgICAgIGNpbiA+PiBBLCBzdW0gKz0gQSwgc3VtICU9IE0sIGNvdW50WyBzdW0gXSsrOwogCiAgICBmb3IoIGF1dG8gcDogY291bnQgKQogICAgewogICAgICAgIGxsIGsgPSBwLnNlY29uZDsKIAogICAgICAgIGlmICggcC5maXJzdCA9PSAwICkKICAgICAgICAgICAgayAqPSBrICsgMTsKICAgICAgICBlbHNlCiAgICAgICAgICAgIGsgKj0gayAtIDE7CiAKICAgICAgICBrID4+PSAxLCBwYWlycyArPSBrOwogICAgfQogCiAgICBjb3V0IDw8IHBhaXJzOwp9