#include <iostream>
#include <stack>
#include <map>

#define ll long long
using namespace std;
ll N,M;
ll A[101234];
ll ans=0,a;
map<ll,ll> llmap;
int i,j,k;
ll a,b;

int main(){
    cin>>N>>M;
    for(i=1;i<=N;i++){
        cin>>A[i];
    }
    map[0]=1;
    for(i=0;i<=N;i++){
        a=(a+A[i])%M;
        llmap[a]++;
    }
    for(auto l:llmap){
        ans+=(l.second-1)*l.second/2;
    }
    cout<< ans<<endl;
    return 0;
}