import sys
input = sys.stdin.readline
print = sys.stdout.write

def radix_sort(nums):
    maxNum = max(nums)
    maxLen = len(str(maxNum))

    for i in range(maxLen):
        radix = [[] for _ in range(10)]
        
        for num in nums:
            digit = (num // (10 ** i)) % 10
            radix[digit].append(num)
        
        nums = [num for bucket in radix for num in bucket]

    return nums


N = int(input())

nums = []
positive = []
negative = []
for i in range(N):
    a = int(input())
    if a < 0:
        negative.append(a)
    else:
        positive.append(a)


positive = radix_sort(positive)
if negative:
    negative = [(-1 * num) for num in negative]
    negative = radix_sort(negative)
    negative = [(-1 * num) for num in negative]
    negative.reverse()
    nums = negative + positive
else:
    nums = positive


for n in nums:
    print(str(n) + '\n')
