#include <bits/stdc++.h>

using namespace std;

int a[101010];
unordered_map<int, int> cnt;

int main() {
	long long ans = 0;
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		if (i) a[i] += a[i - 1];
		a[i] %= m;
		if (a[i] % m == 0) ans += 1;
		ans += cnt[a[i]];
		cnt[a[i]] += 1;
	}

	printf("%lld\n", ans);
	return 0;
}