(n,k),a = $<.map{|l|l.split.map(&:to_i)}

accum = [0]
modk = [0]
sum = 0
a.each.with_index(1){|ai,i|
  sum += ai
  accum << sum
  modk << (sum-i)%k
}

modk += [k]*k

valmap = [0]*(k+1)
l = 0
r = k+l-1

(l+1..r).each{|i|
  valmap[modk[i]] += 1
}
cnt = 0
n.times{
  cnt += valmap[modk[l]]
  l += 1
  r += 1
  valmap[modk[l]] -= 1
  valmap[modk[r]] += 1
}
p cnt