#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<map>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,m,s,x;
map<int,int> q;
long long ans;
int main(){
	scanf("%d%d",&n,&m);
	q[0]=1;
	fo(i,1,n){
		scanf("%d",&x);
		s=(s+x)%m;
		if (q.count(s)) ans+=q[s];
		q[s]++;
	}
	printf("%lld\n",ans);
	return 0;
}