#include<iostream>
#include<algorithm>
#include<map>
using lint=int64_t;
using namespace std;

int main()
{
	lint N,M;
	lint A[100010]={};

	cin >> N >> M;
	for(lint i=1;i<=N;i++)
	{
		cin >> A[i];
		A[i]+=A[i-1];
	}

	map<lint,lint> m;
	for(lint i=1;i<=N;i++)
		m[A[i]%M]++;
	m[0]++;

	lint ans=0;
	for(auto&& i:m)
		ans+=(i.second*(i.second-1))/2;

	cout << ans << endl;
	return 0;
}
