#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M, A;
	long long count = 0, ans = 0;
	map<long long, long long> mp;
	mp[0]++;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A;
		count += A % M;
		count = count % M;
		mp[count]++;
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans += (it->second - 1) * it->second / 2;
	}
	cout << ans;
}