#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, temp;
  cin >> n >> k;
  int arr[n], sum[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0)
      sum[i] = 0;
    else
      sum[i] = sum[arr[i] - 1];
    temp = i > k ? k : i;
    temp += i + k < n ? k : (n - i - 1);
    temp++;
    if (arr[i] + k > i - k && arr[i] != 0) {
      if (arr[i] + k > n)
        temp = 0;
      else if (i - k < 0)
        temp -= arr[i] + k;
      else
        temp -= arr[i] + k - i + k;
    }
    sum[i] += temp;
    cout << sum[i] << " ";
  }
  cout << endl;
}
