#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	map<ll,ll> m;
	m[0] ++;
	ll a,b,temp;
	scanf("%lld%lld",&a,&b);
	ll sum = 0;
	ll ans = 0;
	for(int i = 0;i < a;i ++)
	{
		scanf("%lld",&temp);
		sum = (temp+sum)%b;
		ans += m[sum]++;
	}
	printf("%lld",ans);
	return 0;
}
