#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<long long> dp(n);
  vector<int> r(n);
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) {
      dp[i] = min(n - 1, i + k) - max(0, i - k) + 1;
      r[i] = min(n - 1, i + k);
    } else {
      int to = a[i];
      dp[i] = min(n - 1, i + k) - max(i - k, r[to] + 1) + 1 + dp[to];
      r[i] = min(n - 1, i + k);
    }
    if (i > 0) cout << " ";
    cout << dp[i];
  }
  cout << '\n';
  return 0;
}
