#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(n, 0);
  for (int x = 0; x < n; x++) {
    int l;
    cin >> l;
    if (l != 0) {
      dp[x] = min(2 * k, x - l) + 1;
      dp[x] += dp[l - 1];
    } else {
      dp[x] = min(k, x) + 1;
    }
    cout << dp[x] + min(k, n - x - 1) << " ";
  }
}
