#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

typedef long long ll;
ll n, m, ans, a ,s;
map<ll, ll> d;
int main()
{
	ll i;
	cin >> n >> m;
	d[0]++;
	for (i = 0; i <n; i++) {
		scanf ("%lld", &a);
		s += a;
		s %= m;
		ans += d[s];
		d[s]++;
	}
	cout << ans;
    return 0;
}
