
Copy
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> C(N + 1);
	C[0] = 0;
	map<int, int> mp;
	mp[0] = 1;
	for (int i = 0; i < N; i++) {
		C[i + 1] = (C[i] + A[i]) % M;
		mp[C[i + 1]]++;
	}
	for (auto m : mp) {
		//cerr << m.first << " " << m.second << endl;
		res += (m.second - 1) * m.second / 2;
	}
	cout << res << endl;
}