#include<cstdio>
#include<unordered_map>
int main(){
using u64=unsigned long long;
unsigned int n,m;
scanf("%u%u",&n,&m);
std::unordered_map<unsigned int,unsigned int> mp;
unsigned int a=0,b;
u64 cnt=0;
mp[0]=1;
while(nｰｰ){
scanf("%u",&b);
a=(a+b)%m;
cnt+=mp[a]++;
}
printf("llu\n",cnt);
return 0;
}
