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