#include <bits/stdc++.h>
using namespace std;
long long int n, k, p[100005];
long long int dp[100005];
long long int f(long long int s) {
  if (dp[s] != -1) return dp[s];
  if (p[s] == 0) {
    long long int lo = max(0LL, s - k - 1);
    long long int hi = min(n, s + k);
    return dp[s] = max(0LL, hi - lo);
  }
  long long int lo = max(p[s] + k, max(0LL, s - k - 1));
  long long int hi = min(n, s + k);
  dp[s] = f(p[s]) + max(0LL, hi - lo);
  return dp[s];
}
int main() {
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) cin >> p[i];
  memset(dp, -1, sizeof(dp));
  for (long long int i = 1; i <= n; i++)
    if (dp[i] == -1) f(i);
  for (long long int i = 1; i <= n; i++) cout << dp[i] << " ";
}
