#include <bits/stdc++.h>
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int dp[n];
  for (int i = 0; i < n; i++) {
    int link;
    scanf("%d", &link);
    int first = i - k, last = i + k, prev = 0;
    if (link != 0) {
      prev = dp[link - 1];
      first = link + k > first ? link + k : first;
    }
    if (first < 0) {
      first = 0;
    }
    if (first >= n) {
      first = n;
    }
    if (last >= n) {
      last = n - 1;
    }
    dp[i] = last - first + 1 + prev;
    printf("%d ", dp[i]);
  }
  return 0;
}
