#include <bits/stdc++.h>
#define LL long long
using namespace std;
map<LL,LL>Map;
LL N,M,Sum,Ans;
int main(){
    LL I,J,K;
    scanf("%lld%lld",&N,&M);
    Map[0]++;
    for(I=1;I<=N;I++){
        LL Num;
        scanf("%lld",&Num);
        Sum=(Num+Sum)%M;Ans+=Map[Sum]++;
    } 
    printf("%lld",Ans);
    return 0;
}