#include <bits/stdc++.h>

using namespace std;

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int sum = 0;
	long long ans = 0;
	map<int, int> mod;
	mod[0] = 1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		sum = (sum + x) % m;
		if (!mod.count(sum)) {
			mod[sum] = 0;
		}
		ans += mod[sum];
		mod[sum] += 1;
	}
	printf("%lld\n", ans);
	return 0;
}