#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	long long ans = 0;
	int acc = 0;
	unordered_map<int, int> h;

	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		acc = (0LL + acc + A) % M;
		if (acc == 0) {
			++ans;
		}
		ans += h[acc];
		++h[acc];
	}
	cout << ans << endl;
}
