import sys
n = int(sys.stdin.readline().rstrip())
alis = list(map(int, sys.stdin.readline().
strip().split()))
s = int(sys.stdin.readline().rstrip())
for i in range(1,s+1) :
#print(alis[i-1], alis[i])
idx=1
while idx<n:
if alis[idx]>alis[idx-1] :
tmp = alis[idx]
alis[idx] = alis[idx-1]
alis[idx-1] = tmp
break
else : idx+=1
for a in alis : print(a, end=" ")