#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
    ll N,M; cin>>N>>M; ll A[N],B[N+1]={};
    rep(i,N) cin>>A[i]; B[i+1]=(B[i]+A[i])%M;
    map<ll,ll> ct;
    rep(i,N+1) ++ct[B[i]];
    ll ans=0; 
    for(auto x:ct) ans+=(x.second*(x.second-1))/2;
    cout<< ans<<"\n";
}
