#include<iostream>
#include<algorithm>
using namespace std;
void filter_middle(int w, int n) {
int a[100] = { 0 }; int b[100] = { 0 }; int c[20];
for (int i = 0; i < n; i++) {
cin >> a[i]; b[i] = a[i];
}
int begin = 0; int mid = (begin + begin + w) / 2;
while (begin <= n - w) {//最大滤波边界 小于 滤波窗口长度
for (int i = 0; i < w; i++) c[i] = a[begin + i];// 取出子序列,原序列保持不变
stable_sort(c, c+w);
b[mid+begin] = c[mid];
begin++;
}
for (int i = 0; i < n; i++) {
cout << b[i]<<" ";
}
cout << endl;
}
int main() {
int w;
int n;
while (cin>>w>>n) {
if (w % 2 == 0)printf("ERROR\n");
else
filter_middle(w, n);
}
return 0;
}