#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int a[100000] = {
      0,
  };
  int n, k, res, sum = 0, p, s = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    sum = 2 * k;
    if (i - k < 0) sum -= abs(i - k);
    if (i + k >= n) sum -= (i + k - (n - 1));
    cin >> p;
    if (p > 0) {
      int pr = 0;
      if ((i - (p - 1)) < (2 * k + 1)) pr = 2 * k + 1 - (i - (p - 1));
      if (p - 1 + k >= n) pr -= p - 1 + k - (n - 1);
      s = a[p - 1] - pr;
      if (s < 0) s = 0;
    }
    a[i] = a[i] + 1 + sum + s;
    s = 0;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
