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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	// freopen("input.txt","r",stdin);
	
	long long n,m;
	cin >> n >> m;

	long long array[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> array[i];
	}

	int RemainderSumArray[m] = {0};
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		sum += array[i];
		sum %= m;
		RemainderSumArray[sum]++;
	}



	long long pairs = 0;

	for (int i = 0; i < m; ++i)
	{
		if (RemainderSumArray[i] > 1)
		{
			pairs += (RemainderSumArray[i]*(RemainderSumArray[i] - 1))/2;
		}
	}
	pairs += RemainderSumArray[0];

	cout << pairs << endl;


	return 0;
}
