class Node:
    def __init__(self,id):
        
        self.id=id
    def __lt__(self,other):
        if str(self.id)+str(other.id)>str(other.id)+str(self.id):
            return True
            
n=int(input())
s=list(map(int,input().split()))
lst=list()
s.sort(reverse=True)
for item in s:
    lst.append(Node(item))
lst.sort()
for item in lst:
    print(item.id,end="")

/**************************************************************
	Problem: 1451
	User: admin
	Language: Python
	Result: Accepted
	Time:184 ms
	Memory:34480 kb
****************************************************************/