#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long i, x;
  vector<long long> a;
  map<long long, long long> mp, mb, mf;
  for (i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  long long p = 1;
  long long ans;
  for (i = 0; i < n; i++) {
    ans = 1;
    long long diff = p - a[i] - 1;
    if (k <= n - p) {
      ans += k;
      mf[p] = k;
    } else {
      ans += n - p;
      mf[p] = n - p;
    }
    if (k <= p - 1) {
      ans += k;
      mb[p] = k;
    } else {
      ans += p - 1;
      mb[p] = p - 1;
    }
    ans += mp[a[i]];
    long long x = mb[p] + mf[a[i]];
    if (diff < x) ans -= (x - diff);
    mp[p] = ans;
    p++;
  }
  for (i = 1; i <= n; i++) cout << mp[i] << " ";
  cout << "\n";
}
