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

const int N = 1e5 + 5;

int n, m;
int a[N];
map<int,int> cnt;
long long res = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	cnt[0]++;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] = (a[i] + a[i - 1]) % m;
		res += cnt[a[i]];
		cnt[a[i]]++;
	}
	cout << res << '\n';
}