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

int n;
long m, a, c[100010], s, t;

int main(){
	cin >> n >> m;
	c[0] = 0;
	for (int i = 0; i < n; ++i){
		cin >> a;
		c[i+1] = (c[i] + a) % m;
	}
	sort(c, c+n+1);
	s = 0;
	t = 1;
	for (int i = 1; i <= n; ++i){
		if (c[i] == c[i-1]) t++;
		else{
			s += t*(t-1)/2;
			t = 1;
		}
	}
	s += t*(t-1)/2;
	cout << s;
}