n=int(input())
d=list(map(int,input().split()))
x=int(input())
if x == 0:
    for i in sorted(d):
        print(i,end=" ")
else:
    d=sorted(d,reverse=True)
    for i in d:
        print(i,end=" ")