#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
int n,k;
cin >> n >> k;
int Max = -100001;
int Min = 100001;
for(int i = 0; i < n; i++) {
cin >> a[i];
Max = max(Max , a[i]);
Min = min(Max , a[i]);
}
for (int i = 0; i < n; i++) {
if (a[i] > k) {
a[i] = Max;
}
if (a[i] < k) {
a[i] = Min;
}
cout << a[i] << " ";
}
return 0;
}