#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
int dp[MAXN];
int ssilka[MAXN];
struct newMessages {
  int left, right;
};
int main() {
  dp[0] = 0;
  newMessages t;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> ssilka[i];
  }
  for (int i = 1; i <= n; i++) {
    t.left = max(1, i - k);
    t.right = min(n, i + k);
    if (ssilka[i] > 0) {
      t.left = max(t.left, ssilka[i] + k + 1);
    }
    dp[i] = dp[ssilka[i]] + max(t.right - t.left + 1, 0);
  }
  for (int i = 1; i <= n; i++) cout << dp[i] << ' ';
  return 0;
}
