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

const int N = 1e5 + 10;

ll n, m, a[N];

map<ll, ll> cnt;

ll ans, s[N];

int main() {
	cin >> n >> m;
	for(int i = 1 ; i <= n ; ++ i) cin >> a[i], s[i] = s[i - 1] + a[i];
	cnt[0] = 1;
	for(int i = 1 ; i <= n ; ++ i) {
		ll t = s[i] % m;
		ans += cnt[t];
		++ cnt[t];
	}
	cout << ans << endl;
}