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