#include <iostream>
using namespace std;
int main() {
int n, k, i;
cin >> n;
int dulces[n];
for (i=0; i<n; i++) cin >> dulces[i];
cin >> k;
int valMin = k-3;
int valMax = k+3;
for (i=0; i<n; i++)
if (dulces[i] >= valMin && dulces[i] <= valMax)
cout << dulces[i] << ' ';
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbiwgaywgaTsKCWNpbiA+PiBuOwoJaW50IGR1bGNlc1tuXTsKCWZvciAoaT0wOyBpPG47IGkrKykgY2luID4+IGR1bGNlc1tpXTsKCWNpbiA+PiBrOwoJaW50IHZhbE1pbiA9IGstMzsKCWludCB2YWxNYXggPSBrKzM7Cglmb3IgKGk9MDsgaTxuOyBpKyspCgkJaWYgKGR1bGNlc1tpXSA+PSB2YWxNaW4gICYmIGR1bGNlc1tpXSA8PSB2YWxNYXgpCgkJCWNvdXQgPDwgZHVsY2VzW2ldIDw8ICcgJzsKCXJldHVybiAwOwp9