n = int(input()) list1 =list(map(int,input().split())) op = int(input()) if op == 0: list1.sort() elif op == 1: list1.sort() list1 = list1[::-1] list1 = list(map(str,list1)) print(" ".join(list1))