#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define LLINF 1234567890987654321
#define ph push
#define ins insert
#define db 0
#define f first
#define s second
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
map <ll, ll> mp;
ll n, m, ans, A[100001], sum[100001];
void make_sum(ll i)
{
	if(i==0)sum[i] = A[i];
	else sum[i] = sum[i-1] + A[i];
}
ll get_sum(ll x, ll y)
{
	if(x == 0)return sum[y];
	else return sum[y] - sum[x-1];
}
int main()
{
	cin >> n >> m;
	for(ll i = 0; i < n; i++)cin >> A[i];
	for(ll i = 0; i < n; i++)make_sum(i);
	mp[0] = 1;
  ll lol=0;
	for(ll i = 0; i < n; i++)
	{
		lol+=A[i];
      	sum=lol;
		ans += mp[sum%m];
		mp[sum%m]++;
	}
	cout << ans << '\n';
}
