#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,m,a[200100];
long long Ans;
map<int,int> M;
signed main()
{
	cin >> n >> m; a[0]=1;
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),
		a[i]=(1ll*a[i-1]+a[i])%m;
	for(int i=0;i<=n;i++)
		Ans+=M[a[i]],M[a[i]]++;
	cout << Ans << endl;
	return 0;
}