while True: try: n = int(input()) array = list(map(int, input().split())) t = int(input()) def sortArray(x, y): if y == 0: return sorted(x) if y == 1: return sorted(x, reverse = True) s = sortArray(array, t) for i in range(len(s)): print( s[i], end = ' ') except: break