#include <bits/stdc++.h>
#define int long long
using namespace std;
int z,d,ans,sum;
map<int,int>mp;
signed main(){
    cin>>z>>d;
    while(z--){
        int x;
        cin>>x;
        mp[sum]++;
        ans += mp[(d * 2'000'000'0000 - x) % d];
        sum+=x;
        sum%=d;
        mp[sum]++; 
    }
    cout<<ans/2<<'\n';
}
