#include <iostream>
#include <map>
using namespace std;

int n;
long m, a, c, s;
map<long, long> x;

int main(){
	cin >> n >> m;
	x.emplace(0, 1);
	c = 0;
	for (int i = 0; i < n; ++i){
		cin >> a;
		c = (c + a) % m;
		if (x.find(c) != x.end()) x.at(c)++;
		else x.emplace(c, 1);
	}
	s = 0;
	for (auto &e: x){
		s += e.second*(e.second-1)/2;
	}
	cout << s;
}