
#include<iostream>
#include<unordered_map>
#include<numeric>

using ui  = unsigned int;
using ull = unsigned long long;

int main() {
	ui n, m;
	std::cin >> n >> m;

	std::unordered_map<ui,ui> mp;
	
	// small type version
	ui accum = 0;
	mp[0] += 1;
	for (ui i{}; i < n; ++i) {
		ui ai;
		std::cin >> ai;
		accum += ai;
//		accum %= m;
//		std::cout << accum << " ";
		mp[accum %= m] += 1;

	}

	auto ans 
		=	std::accumulate(
				std::begin(mp)
				,std::end(mp)
				, ull{}
				, [](auto init, auto x) {
					const auto& t = x.second;
					//std::cout << t << " ";
					return
						init += t <= 1 ? 0 : t * (t - 1) / 2;
				}
			);

	std::cout << ans << "\n";

	return 0;
}