#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[100000], vis[100000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < (n); i++) {
    int loReach = max(0, i - k);
    int hiReach = min(n - 1, i + k);
    if (a[i] == -1) {
      vis[i] = hiReach - loReach + 1;
    } else {
      int e = min(n - 1, a[i] + k);
      vis[i] = vis[a[i]] + hiReach - max(e, loReach - 1);
    }
  }
  for (int i = 0; i < (n); i++) cout << vis[i] << " ";
  return 0;
}
