#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int cnt[1000000000];

int main()
{
    ll N,M;
	cin >> N >> M;
	vector<ll> A(N);
	cin >> A[0];
	for(int i=1; i<N; i++){
		ll tmp;
		cin >> tmp;
		A[i]=tmp+A[i-1];
	}
	ll ans=0;
	for(auto a: A){
		ll tmp=a%M;
		if(tmp==0) ans++;
		ans+=cnt[tmp];
		cnt[tmp]++;
	}
	cout << ans << endl;

	

    return 0;
}
