#include <bits/stdc++.h>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> s;
	s[0] = 1;
	int a, b = 0;
	long r = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		b += a; b %= m;
		r += s[b]++;
	}
	cout << r << endl;
	return 0;
}
