#include <bits/stdc++.h>
using namespace std;
void KeepTrying() {
  int n, k;
  cin >> n >> k;
  vector<int> V(n + 1);
  for (int i = 1; i <= n; i++) cin >> V[i];
  vector<int> DP(n + 1);
  for (int i = 1; i <= n; i++) {
    int l = max(1, i - k), r = min(n, i + k);
    int a = V[i];
    DP[i] = DP[a] + r - l + 1;
    if (a) {
      int rightOfprevMessage = min(n, a + k);
      DP[i] -= max(0, rightOfprevMessage - l + 1);
    }
  }
  for (int i = 1; i <= n; i++) cout << DP[i] << " \n"[i == n];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int DontGiveUp = 1;
  while (DontGiveUp--) KeepTrying();
  return 0;
}
