#include <bits/stdc++.h>

using namespace std;

int n, m;
map<int, int> mm;
long long ans, sum, ta;

int main() {
	mm[0] = 1;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &ta);
		sum += ta;
		sum %= m;
		ans += mm[sum];
		mm[sum]++;
	}
	printf("%lld\n", ans);
	return 0;
}
