#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return a > b; }
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<int> dp(n + 1, 0);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (v[i - 1] == 0) {
      int l = max(1, i - k);
      int r = min(i + k, n);
      dp[i] = r - l + 1;
    } else {
      int l = max(1, i - k);
      int r = min(i + k, n);
      int r1 = min(v[i - 1] + k, n);
      if (r1 < l) {
        dp[i] = dp[v[i - 1]] + r - l + 1;
      } else {
        dp[i] = dp[v[i - 1]] + r - r1;
      }
    }
  }
  for (long long i = 1; i < n + 1; i++) cout << dp[i] << " ";
}
int main() {
  int t;
  t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
}
