#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-12;
const int MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e5 + 4;
const int maxm = 1e4 + 4;
inline long long rule(long long x) { return (x %= MOD) += x < 0 ? MOD : 0; }
int cnt[maxn], l[maxn], r[maxn], n, K, f[maxn];
int main() {
  int ik, i, j, k, kase;
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; ++i) scanf("%d", f + i);
  for (int i = 1; i <= n; ++i) {
    l[i] = max(i - K, 1);
    r[i] = min(i + K, n);
    if (f[i] == 0) {
      cnt[i] = r[i] - l[i] + 1;
    } else {
      cnt[i] = cnt[f[i]];
      if (r[f[i]] >= l[i]) {
        cnt[i] += r[i] - r[f[i]];
      } else
        cnt[i] += r[i] - l[i] + 1;
    }
    printf("%d ", cnt[i]);
  }
  return 0;
}
