#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ll n,m;
cin>>n>>m;
vector<ll> a(n);
for(auto& h : a)cin>>h;
vector<ll> b(n+1,0);
for(int i=0;i<n;++i)
b[i+1]=(b[i]+a[i])%m;
map<ll,ll> x;
for(auto h : b)
x[h]++;
ll ans=0;
for(auto h : x)
ans+=h.second*(h.second-1)/2;
cout<<ans<<endl;
}
