只是排序

while True:
    try:
        num = int(input())
        a = list(map(int,input().split()))
        b = int(input())
        if(b == 0):
            a.sort()
            print(*a)
        if(b == 1):
            a.sort(reverse = True)
            print(*a)
    except:
        break