#include <bits/stdc++.h>
using namespace std;
int n, k;
long long m[101010][3];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, l, r;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> m[i][0];
  }
  for (i = 1; i <= n; i++) {
    l = max(max((long long)i - k, m[m[i][0]][2] + 1), 1ll);
    r = min(i + k, n);
    m[i][1] = m[m[i][0]][1] + r - l + 1;
    m[i][2] = r;
  }
  for (i = 1; i <= n; i++) {
    cout << m[i][1] << " ";
  }
  return 0;
}
