#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() 
{
	int n,m;
	cin >> n >> m;
	int a[n];
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int sum = 0;
	int modarray[m] = {0};
	
	for(int i = 0; i < n; i++)
	{
		sum = sum + a[i];
		modarray[((sum % m) + m) % m]++;
	}
	
	int count = 0;
	
	for(int i = 0; i < m; i++)
	{
		if(modarray[i] > 1)
		{
			count += modarray[i] * (modarray[i] - 1) / 2;
		}
	}
	count += modarray[0];
	cout << count << endl;
	return 0;
}