#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	long long int p,d,ans=0,y=0,z=0;
 	cin >> p>>d;
 	vector <int> b;
 	int a[p]{0};
 	a[0]++;
 	for (int i = 0; i < p; i++){
 		int x;
 		cin >> x;
 		y=(x+y)%d;
 		b.push_back(y);
 		auto itr = find(b.begin(), b.end(), y);
 		int h=itr-b.begin();
 		a[h]++;
 		if(z<h){
 			z=h;
 		}
 	}
 	for (int i = 0; i <= z; i++){
 		ans=ans+a[i]*a[i]-a[i];
 	}
 	cout << ans/2 << endl;
 }