#include<bits/stdc++.h>
using namespace std;
int m,n,i,j;
#define maxn 200010
long long a[maxn],sum[maxn],k,ans;
map<long long,long long>mp;
int main()
{
	scanf("%d%lld",&n,&k);
	mp[0]++;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum[i]=(sum[i-1]+a[i])%k;
		mp[sum[i]-i]++;
	}
	map<long long,long long>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)
	{
		long long p=it->second;
		ans+=p*(p-1)/2;
	//	printf("%lld %lld\n",it->first,it->second);
	}
	printf("%lld\n",ans);
	return 0;
}