#include <bits/stdc++.h>
using namespace std;
int a[111111];
long long b[111111];
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    b[i] = b[a[i]];
    int y = min(i + k, n), x;
    if (a[i] > 0)
      x = max(a[i] + k + 1, max(i - k, 1));
    else
      x = max(i - k, 1);
    if (y >= x) b[i] += (y - x + 1);
    cout << b[i] << " ";
  }
  return 0;
}
