#include <iostream>
#include <unordered_map>
using namespace std;

int main() {
int n,m;
long long b[100001],c=0;
unordered_map<int,int> p{};
cin>>n>>m;
b[0]=0;
p[0]=1;
for(int i=1;i<=n;i++){
    cin>>b[i];
    b[i]+=b[i-1];
    b[i]%=m;
    p[b[i]]=p[b[i]];
    p[b[i]]++;
}
for(auto i=p.begin();i<p.end();i++){
    long long y=i->second;
    c+=y*(y-1)/2;
}
cout<<c<<endl;
	return 0;
}