#include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
int n,m;
int a[N],s[N];
map<int,int> v;
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int ans=0;v[0]++;
	for(int i=1;i<=n;i++)
	{
		s[i]=(s[i-1]+a[i])%m;
		ans+=v[s[i]];v[s[i]]++;
	}
	cout<<ans;
	
	
	
}