#include <bits/stdc++.h>
using namespace std;
int a, l[120001], r[120001], ans[120001], n, i, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    l[i] = max(i - k, 1);
    r[i] = min(i + k, n);
  }
  for (i = 1; i <= n; i++) {
    cin >> a;
    if (a == 0) {
      ans[i] = r[i] - l[i] + 1;
      continue;
    }
    ans[i] = ans[a] + r[i] - l[i] + 1 - max(r[a] - l[i] + 1, 0);
  }
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << '\n';
  return 0;
}
