#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int* N = (int*)malloc((n + 1) * sizeof(int));
	N[0] = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &N[i]);
		N[i] = (N[i - 1] + N[i]) % k;
	}
	int tmp, num = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = i + 1; j <= n && j < i + k; j++) {
			tmp = N[j] - N[i];
			if (tmp < 0)tmp += k;
			if (tmp == j - i) num++;
		}
	}
	cout << num << endl;
	return 0;
}