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

 int main()
 {
 	long long int p,d,ans=0,y=0;
 	cin >> p>>d;
 	vector <int> a;
 	a.push_back(0);
 	for (int i = 0; i < p; i++){
 		int x;
 		cin >> x;
 		y=x+y;
 		a.push_back(y%d);
 	}
 	}
 	cout << endl;
 	int c =count(a.begin(),a.end(),0);
 	ans=ans+c*c-c;
 	for (int i = 1; i < d; i++){
 		int h=count(a.begin(),a.end(),i);
 		ans=ans+h*h-h;
 	}
 	cout << ans/2 << endl;
 }