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

int n,m, s = 0;
long long res = 0;
unordered_map<int, long long> a;

int main(){
	cin >> n >> m;
	a[0] = 1;
	for (int i=1; i<=n; ++i){
		int tmp;
		cin >> tmp;
		s = (s+tmp)%m;
		if (a.find(s) == a.end()){
			a[s] = 1;
		}
		else{
			res += a[s];
			a[s]++;
		}
	}
	cout << res;
	return 0;
}