#include<bits/stdc++.h>
#define int long long
using namespace std;

unordered_map<int,int>U;
signed main(){
int n,m;cin>>n>>m;
U[0]++;
int sum=0;
for(int i=0;i<n;i++){
int a;cin>>a;
sum+=a;
U[sum%m]++;
}
int ans=0;
for(auto i:U){ans+=i.second*(i.second-1)/2;}
  cout<<ans<<endl;
}