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