#include<iostream>
#include<map>
using namespace std;
using ll = long long;

int main() {
	ll n, m, ans = 0, now = 0;
	cin >> n >> m;
	map<ll, ll>mp;
	mp[0]++;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		now += a;
		now %= m;
		ans += mp[now];
		mp[now]++;
    }
	cout << ans << endl;
}