#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
int main() {
	lint n, m, in, s = 0, ans = 0; cin >> n >> m;
	unordered_map<lint, lint> h;
	++h[0];
	for (int i = 0; i < n; ++i) {
		cin >> in;
		s = (s + in) % m;
		++h[s];
	}
	for (auto i : h) {
		ans += i.second*(i.second - 1) / 2;
	}
	cout << ans << endl;
}