#include<stdlib.h>
#define ll long long
m;b;l;i;
ll r;
int cmp(ll*a,ll*b){return *a-*b;}
main(n){
    scanf("%d",&n);scanf("%d",&m);
    ll a[n+1];
    for (l=n,a[0]=0;n>0&&scanf("%d",&b);--n)a[l-n+1]=(b+a[l-n])%m;
    qsort(a,l+1,sizeof(int),cmp);
    for (i=1,n=0;n<l;++n){while (n<l&&a[n+1]==a[n]){++i;++n;}r+=i*(i-1)/2;i=1;}
    printf("%lld",r);
}