#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	int asum[m]={};
	int t;
	cin>>t;
	t=t%m;
	asum[t]++;
	for(int i=1;i<n;i++){
		int tl;
		cin>>tl;
		t=(t+tl)%m;
		asum[t]++;
	}
	ll res=asum[0];
	for(int i=0;i<m;i++){
		res+=asum[i]*(asum[i]-1)/2;
	}
	cout<<res<<endl;
	return 0;
}