#include<iostream>
#include<map>
using namespace std;
int main(){
    long N,M,ans=0L;cin>>N>>M;
    map<long,long>m;
    for(long i=0,A,acc=0L;i<N;acc+=A,m[acc%M]++,i++)cin>>A;
    for(auto x:m)ans+=x.second*(x.second-1L)/2L;
    cout<<ans+m[0]<<endl;
    return 0;
}