a = input()
b = list(map(int,input().split()))
c = int(input())
if c == 0:
    b.sort()
    print(' '.join('%s' %id for id in b))
elif c == 1:
    b.sort(reverse = True)
    print(' '.join('%s' %id for id in b))