#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <deque>
#include <set>
#include <random>
#include <cassert>
#include <chrono>
#include <bitset>
using namespace std;
const int MAXN = 2e5 + 10;
const int MAXA = 1000;
bitset<MAXN> bad_pos[MAXA];
void solve() {
int n, k;
cin >> n >> k;
vector <int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i]; --a[i];
}
vector <int> ans(2 * n - 1);
for (int val = 0; val < MAXA; ++val) {
for (int i = 0; i < n; ++i) {
if (abs(a[i] - val) > k) bad_pos[val].set(i);
}
}
bitset<MAXN> cur_positions;
bitset<MAXN> tmp;
for (int i = 0; i < n; ++i) {
ans[2 * i] = 2 * min(i + 1, n - i) - 1;
}
for (int i = 0; i < n - 1; ++i) {
ans[2 * i + 1] = 2 * min(i + 1, n - i - 1);
}
for (int r = 0; r < n; ++r) {
cur_positions.set(r);
if (r) cur_positions.set(r - 1);
tmp = cur_positions & bad_pos[a[r]];
int cha = tmp._Find_first();
while (cha != MAXN) {
ans[cha + r] = r - cha + 1;
cur_positions.reset(cha);
cha = tmp.Find_next(cha);
}
cur_positions <<= 1;
}
for (int i = 0; i < n; ++i) cout << ans[2 * i] << " ";
for (int i = 0; i < n - 1; ++i) cout << ans[2 * i + 1] << " ";
}
signed main() {
if (1) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int t = 1;
while (t--) {
solve();
}
return 0;
}
/*
5 7
1 2
1 3
2 4
2 5
A 1 4 2
A 3 5 2
D 1 4
D 2 3
D 2 1
A 5 5 10
D 5 100
*/