#include <bits/stdc++.h>
using namespace std;
int a[100001], c[100001];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  c[0] = 0;
  for (int i = 1; i <= n; i++) {
    int l = k, r = k, sum = 0;
    if (i - 1 < l) l = i - 1;
    if (n - i - 1 < r) r = n - i;
    sum = 1 + r + l + c[a[i]];
    r = k;
    if (n - a[i] < k) r = n - a[i];
    int g = i - a[i] - r - l - 1;
    if (g > 0 || a[i] == 0) g = 0;
    c[i] = sum + g;
  }
  for (int i = 1; i <= n; i++) cout << c[i] << " ";
}
