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

typedef long long ll;

int n, m;
map <int, int> M;
ll res;

int main()
{
	cin >> n >> m;
	M[0]++;
	int cur = 0;
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		cur = (cur + a) % m;
		res += M[cur]++;
	}
	cout << res << endl;
	return 0;
}