# 思路:排序标识参数化
while True:
try:
n = int(input())
l = list(map(int,input().split()))
flag = int(input())
print(*sorted(l, reverse=flag)) # 排序标识参数化 flag = 0升序;flag = 1降序 except:
break