#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<pair<int, int> > a(maxn);
int link[maxn];
int add(pair<int, int> x, pair<int, int> y) {
  return y.second - max(x.second + 1, y.first) + 1;
}
int dp[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> link[i];
    a[i] = {max(1, i - k), min(n, i + k)};
    dp[i] = dp[link[i]] + add(a[link[i]], a[i]);
    cout << dp[i] << ' ';
  }
  return 0;
}
