function main(input) {
  var N = input[0].split(" ")[0]-0;
  var K = input[0].split(" ")[1]-0;
  var list = input[1].split(" ").map(v=>v-0);
  var sumlist = [];
  sumlist[0] = 0;
  for(var i=0;i<list.length;i++){
    sumlist[i+1] = (sumlist[i] + list[i])%K;
  }
  var ans = 0;
  for(var i=1;i<=Math.min(K, list.length);i++){
    for(var start=0;start+i<sumlist.length;start++){
      var chk = (K+sumlist[start+i] - sumlist[start]);
      if(chk%K == i) ans++;
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
