#include <bits/stdc++.h>

using namespace std;

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