#include <bits/stdc++.h>
using namespace std;
using ll = long long;

map<ll,ll> ma;

int main(){
    ll n,m,x=0,ans=0;
    cin>>n>>m;
    ma.emplace(0,1);
    for(ll i=0;i < n;i++)
    {
        ll in;cin>>in;
        x+=in;x%=m;    
        if(ma.count(x)) ma.at(x)++;
        else ma.emplace(x,1); 
        ans+=ma.at(x)-1;
    }
    cout << ans << endl;
}