#include <bits/stdc++.h>

using namespace std;

int main(void) {
	long long N, M;
	vector<long long> v;
	map<long long, long long> m;
	cin >> N >> M;
	long long s = 0;
	for(int i = 0; i < N; ++i) {
		long long t;
		cin >> t;
		s += t;
		++m[s % M];
	}
	long long result = 0;
	for(auto const& x : m) {
		result += x.second * (x.second - 1) / 2;
	}
	result += m[0];
	cout << result << '\n';
	return 0;
}

