# Arup Guha
# 12/7/2024
# Sorting Examples

# Gets # of items.
n = int(input())
items = []

# Reads them in.
for i in range(n):
    val = int(input())
    items.append(val)

# Sort the list.
items.sort()

# Output the items in sorted order.
for x in items:
    print(x)

# Reverse the order
items.sort(reverse=True)
print()

# Output the items in sorted order.
for x in items:
    print(x)
