#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k, link;
  cin >> n >> k;
  vector<int> ans(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> link;
    ans[i] = min(n, i + k) - max(1, i - k) + 1;
    if (link != 0) {
      ans[i] += ans[link] - max(0, (min(n, link + k) - max(1, i - k) + 1));
    }
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
