#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long x[1000000005];
int main(void){
    int A[100005],B[100005];
    int n,m; cin>>n>>m;
    long long ans=0;
    B[0]=0;
    for(int i=1;i<=n;i++){
        cin>>A[i];
        B[i]=(B[i-1]+A[i])%m;
        x[B[i]]++;
    }
    x[0]++;
    for(int i=0;i<m;i++){
        ans+=x[i]*(x[i]-1)/2;
    }
    cout<<ans<<endl;
    
}
