#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int N,M;
	cin>>N>>M;
	int A[N];
	rep(i,N) cin>>A[i];
	ll wa[N+1]={};
	ll ans=0;
	rep(i,N) wa[i+1]=wa[i]+A[i];
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N+1; j++){
			if((wa[j]-wa[i])%M==0) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}