n = int(input())
ls = list(map(int, input().split())) # 需要转成整数,才能排序
rnk = int(input())
if rnk == 0:
ls.sort()
ls = map(str,ls) # 需要转回字符串,才能拼接
print(' '.join(ls))
elif rnk == 1:
ls.sort(reverse=True)
ls = map(str, ls)
print(' '.join(ls))