# frozen_string_literal: true def solve a = A.tally len = a.keys.max c = Array.new(len, 0) (D..(len - 1)).each do |i| c[i] = c[i - 1] + (a[i - D + 1] || 0) end A.map { c[_1 - 1] } end N, D = gets.split.map(&:to_i) A = N.times.map { gets.to_i } puts solve