#include<cstdio>
#include<iostream>
using namespace std;
#define M 300000

typedef long long ll;

int n;
ll sumup[M],lltmp,k,ans = 0;

int main(){
	cin >> n >> k;
	cin >> sumup[1];
	for(int i = 2;i <= n;i++){
		scanf("%lld",&lltmp);
		sumup[i] = sumup[i-1]+lltmp;
	}
	
	for(int i = 1;i <= n;i++){
		for(int j = i;j <= n;j++){
			if((sumup[j]-sumup[i-1])%k == 1LL*(j-i+1)) ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}