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

typedef long long ll;
ll n, m, s, c;
map<ll, ll> ma;
int main()
{
	ll t;
	cin >> n >> m;
	ma[0]++;
	while (n--) {
		scanf("%lld", &t);
		s += t;
		c += ma[s % m];
		ma[s % m]++;
	}
    cout << c << endl;
    return 0;
}