def shaku(K,lists):

    ans=0

    SUMS=0

    index=0

    for  l  in range(len(lists)):

        while index < l or index< len(lists) and SUMS +lists[index] < K:

            SUMS += lists[index]

            index+= 1

        ans += index-l

        SUMS -= lists[l]



    return ans





n,k=list(map(int,input().split()))

lists=list(map(int,input().split()))



uselist=[0 for i in range(n+1)]

for i in range(n):

    uselist[i+1]=(uselist[i]+lists[i])

anslist=[0 for i in range(n+1)]

for j in range(1,n+1):

    anslist[j]=(uselist[j]-j)%k

dic={}

for i in range(n+1):

    if anslist[i] in  list(dic.keys()):

        dic[anslist[i]].append(i+1)

    else:

        dic[anslist[i]]=[1+i]

#answerに答えを格納することにする

answer=0

for lis in list(dic.values()): 

    sublis=[lis[0]]

    for a in range(1,len(lis)):

        sublis.append(lis[a]-lis[a-1])

    P=shaku(k,sublis)



    for some in lis:

      if some<k:

        answer-=1

    answer+=P

print(answer)
# Rem of sum is Num

# Reviewing problem





from collections import defaultdict





def cnt_func(X):

    res = 0

    right = 0

    L = len(X)

    for i in range(L):

        while right+1 < L and X[right+1] < K+X[i]:

            right += 1

        res += right-i

    return res





N, K = list(map(int, input().split()))



A = list(map(int, input().split()))

A.insert(0, 0)

for i in range(1, N+1):

    A[i] += A[i-1]

B = [0 for i in range(N+1)]

for i in range(N+1):

    B[i] = (A[i]-i) % K

ans = 0

Mod = defaultdict(list)

for i in range(N+1):

    Mod[B[i]].append(i)

for X in list(Mod.values()):

    ans += cnt_func(X)

print(ans)
def shaku(K, lists):
    ans = 0
    SUMS = 0
    index = 0
    for l in range(len(lists)):
        while index < l or index < len(lists) and SUMS + lists[index] < K:
            SUMS += lists[index]
            index += 1
        ans += index - l
        SUMS -= lists[l]
    return ans


n, k = list(map(int, input().split()))
lists = list(map(int, input().split()))
uselist = [0 for i in range(n + 1)]
for i in range(n):
    uselist[i + 1] = uselist[i] + lists[i]
anslist = [0 for i in range(n + 1)]
for j in range(1, n + 1):
    anslist[j] = (uselist[j] - j) % k
dic = {}
for i in range(n + 1):
    if anslist[i] in list(dic.keys()):
        dic[anslist[i]].append(i + 1)
    else:
        dic[anslist[i]] = [1 + i]
# answerに答えを格納することにする
answer = 0
for lis in list(dic.values()):
    sublis = [lis[0]]
    for a in range(1, len(lis)):
        sublis.append(lis[a] - lis[a - 1])
    P = shaku(k, sublis)
    for some in lis:
        if some < k:
            answer -= 1
    answer += P
print(answer)

# Rem of sum is Num
# Reviewing problem
from collections import defaultdict


def cnt_func(X):
    res = 0
    right = 0
    L = len(X)
    for i in range(L):
        while right + 1 < L and X[right + 1] < K + X[i]:
            right += 1
        res += right - i
    return res


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.insert(0, 0)
for i in range(1, N + 1):
    A[i] += A[i - 1]
B = [0 for i in range(N + 1)]
for i in range(N + 1):
    B[i] = (A[i] - i) % K
ans = 0
Mod = defaultdict(list)
for i in range(N + 1):
    Mod[B[i]].append(i)
for X in list(Mod.values()):
    ans += cnt_func(X)
print(ans)

-def shaku(K, lists): -    ans = 0 -    SUMS = 0 -    index = 0 -    for l in range(len(lists)): -        while index < l or index < len(lists) and SUMS + lists[index] < K: -            SUMS += lists[index] -            index += 1 -        ans += index - l -        SUMS -= lists[l] -    return ans +# Rem of sum is Num +# Reviewing problem +from collections import defaultdict -n, k = list(map(int, input().split())) -lists = list(map(int, input().split())) -uselist = [0 for i in range(n + 1)] -for i in range(n): -    uselist[i + 1] = uselist[i] + lists[i] -anslist = [0 for i in range(n + 1)] -for j in range(1, n + 1): -    anslist[j] = (uselist[j] - j) % k -dic = {} -for i in range(n + 1): -    if anslist[i] in list(dic.keys()): -        dic[anslist[i]].append(i + 1) -    else: -        dic[anslist[i]] = [1 + i] -# answerに答えを格納することにする -answer = 0 -for lis in list(dic.values()): -    sublis = [lis[0]] -    for a in range(1, len(lis)): -        sublis.append(lis[a] - lis[a - 1]) -    P = shaku(k, sublis) -    for some in lis: -        if some < k: -            answer -= 1 -    answer += P -print(answer) +def cnt_func(X): +    res = 0 +    right = 0 +    L = len(X) +    for i in range(L): +        while right + 1 < L and X[right + 1] < K + X[i]: +            right += 1 +        res += right - i +    return res + + +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +A.insert(0, 0) +for i in range(1, N + 1): +    A[i] += A[i - 1] +B = [0 for i in range(N + 1)] +for i in range(N + 1): +    B[i] = (A[i] - i) % K +ans = 0 +Mod = defaultdict(list) +for i in range(N + 1): +    Mod[B[i]].append(i) +for X in list(Mod.values()): +    ans += cnt_func(X) +print(ans)