#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,s[200001],a,L,cnt,ans;
map<ll,ll>mp;
int main(void){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a;
		s[i+1]=s[i]+a;
	}
	for(ll i=0;i<=n;i++){
		s[i]-=i;
		s[i]%=k;
		s[i]=(s[i]+k)%k;
	}
	n++;
	for(int i=0;i<min(n,k);i++){
		ans+=mp[s[i]];
		mp[s[i]]++;
	}
	for(int i=0;i<n-min(n,k);i++){
		mp[s[i]]--;
		ans+=mp[s[i+min(n,k)]];
		mp[s[i+min(n,k)]]++;
	}
	cout<<ans<<endl;
}