#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  int a_i;
  for (int i = 1; i <= n; ++i) {
    cin >> a_i;
    a[i] = a_i;
  }
  vector<int> din(n + 1);
  din[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int count = min(i + k, n) - max(i - k, 1) + 1;
    if (a[i] != 0) {
      count -= max(min(a[i] + k, n) - max(i - k, 1) + 1, 0);
    }
    count += din[a[i]];
    din[i] = count;
  }
  for (int i = 1; i <= n; ++i) {
    if (i != 1) cout << ' ';
    cout << din[i];
  }
  return 0;
}
