#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;
    mp[0]++;
    while(z--){
        int x;
        cin>>x;
        sum+=x;
        sum%=d;
        ans += mp[sum];
        mp[sum]++;
    }
    cout<<ans<<'\n';
}
