#include <bits/stdc++.h>

using namespace std;

void get() {

}

typedef long long ll;
ll a[123456];
unordered_map<ll, int>mp;
// Returns value of Binomial Coefficient C(n, k) O(n)时间, O(1)空间
ll binomialCoeff(int n, int k)
{
	ll res = 1;

	// Since C(n, k) = C(n, n-k)
	if ( k > n - k )
		k = n - k;

	// Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
	for (int i = 0; i < k; ++i)
	{
		res *= ll(n - i);
		res /= ll(i + 1);
	}

	return res;
}
class DCandyDistribution {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m;
		in >> n >> m;
		mp.clear();
		memset(a, 0, sizeof(a));
		ll sum = 0;
		for (int i = 1; i <= n; ++i) {
			in >> a[i];
			a[i] += a[i-1];
			a[i] %= m;
			mp[a[i]]++;
		}
		for (auto it = mp.begin(); it != mp.end(); ++it) {
			if(it->second >= 2 && it->first != 0)sum += binomialCoeff(it->second, 2);
			else if(it->first == 0)sum += binomialCoeff(it->second, 2);
			if(it->first == 0) sum += it->second;
		}
		out << sum << '\n';
	}
};