#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> sum(N + 1);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		sum[i + 1] = (sum[i] + A) % M;
	}
	unordered_map<int, int> cnt;
	ll res = 0;
	for (int i = 0; i <= N; i++) {
		res += cnt[sum[i]]++;
	}
	cout << res << endl;
	return 0;
}
