#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int n,m;
int A[110000];
map<int,int>M;
int main(){
	scanf("%d%d",&n,&m);
	M[0]++; int k1=0; long long ans=0;
	for (int i=1;i<=n;i++){
		int k2; scanf("%d",&k2);
		k1=(k1+k2)%m;
		ans+=M[k1]; M[k1]++;
	}
	cout<<ans<<endl;
}
