#include <bits/stdc++.h>
#pragma GCC optimize("O0")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
long long n, m, a, b, c, k, temp, x, y;
const int MAXN = 100000 + 11;
void read(vector<long long> &v) {
  for (int i = 0; i < v.size(); i++) cin >> v[i];
}
inline long long max(long long a, long long b) { return ((a > b) ? a : b); }
inline long long min(long long a, long long b) { return ((a > b) ? b : a); }
inline long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
void storepowers(int n, vector<int> &a);
void solveforthiscase(const int &test) {
  cin >> n >> k;
  vector<long long> v(n + 10);
  for (int i = 1; i <= n; i++) cin >> v[i];
  long long dp[n + 1];
  dp[0] = 0;
  dp[1] = 1 + min(n - 1, k);
  for (int i = 2; i <= n; i++) {
    dp[i] = 1 + min(n - i, k) + min(i - 1, k) + dp[v[i]];
    if (false) cerr << "dp[i]" << ' ' << '=' << ' ' << dp[i] << '\n';
    if (v[i] != 0) dp[i] -= max(min(v[i] + k, n) - max((i - k), 1) + 1, 0);
  }
  for (int i = 1; i <= n; i++) cout << dp[i] << ' ';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  for (int i = 1; i <= test; i++) {
    solveforthiscase(i);
  }
}
void storepowers(int n, vector<int> &a) {
  a.resize(n + 1);
  a[0] = 1;
  for (int i = 1; i <= n; i++) a[i] = a[i - 1] * 2;
  return;
}
