def func(i,lst,bol):
    i1= int(i)
    bol1 = bool(int(bol))
    lst1 = list(map(int,lst))
    lst1.sort(reverse= bol1)
    lst2 = [ str(x) for x in lst1 ]
    str1 = " "
    return str1.join(lst2)
i = input()
lst = input().split()
bol = input()
print(func(i,lst,bol))