#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int N,M;
ll A[100010] = {0};
int main(){
	cin >> N >> M;
	map<ll,ll> m;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		A[i] += A[i-1];
		m[A[i]%M]++;
//		cout << A[i] << endl;
	}
	ll ans = 0;
	for(auto x:m){
		if(x.first==0) ans += x.second;
	//	cout << x.second << endl;
		ans += x.second*(x.second-1)/2;
	}
	cout << ans << endl;
}