#include <bits/stdc++.h>
using namespace std;

long long n, m, t, a, c;
unordered_map<long long, long long> cnt;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	cnt[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> c; a += c; a %= m;
		t += cnt[a]; cnt[a]++;
	}
	cout << t;
}