#include <bits/stdc++.h>
using namespace std;
int data_message[100001];
int d[100001][2];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> data_message[i];
  }
  d[0][0] = 1 + (n - 1 < k ? n - 1 : k);
  d[0][1] = 1 + (n - 1 < k ? n - 1 : k);
  for (int i = 1; i < n; i++) {
    int prev = data_message[i] - 1;
    int bound = d[prev][1];
    int value = prev == -1 ? 0 : d[prev][0];
    if (bound < i - k + 1) {
      d[i][0] = value + min(i, k) + 1 + (n - i - 1 < k ? n - i - 1 : k);
    } else if (bound < i + 1) {
      d[i][0] = value + 1 + min(i, k) - (1 + bound - max(1, i + 1 - k)) +
                (n - i - 1 < k ? n - i - 1 : k);
    } else if (bound == i + 1) {
      d[i][0] = value + (n - i - 1 < k ? n - i - 1 : k);
    } else {
      d[i][0] = value + (n - i - 1 < k ? n - i - 1 : k) - (bound - i) + 1;
    }
    d[i][1] = min(1 + i + k, n);
  }
  for (int i = 0; i < n; i++) cout << d[i][0] << " ";
  return 0;
}
