#include <bits/stdc++.h>
using namespace std;
int n, k;
int a, dp[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a;
    if (a == 0) {
      dp[i] = 1;
      int low = max(1, i - k);
      int high = min(n, i + k);
      dp[i] += (high - low);
    } else {
      dp[i] = 1;
      int low = max(1, i - k);
      int high = min(n, i + k);
      dp[i] = dp[i] + high - low + dp[a];
      int highFromRef = min(n, a + k);
      if (highFromRef >= low) {
        dp[i] = dp[i] - (highFromRef - low + 1);
      }
    }
    cout << dp[i] << " ";
  }
  cout << "\n";
  return 0;
}
