#50324: python笨方法


nnic52136@gmail.com (李Rr)


while True:
  try:
    n=int(input() )
    b=list (map ( int , input ().split() ) )
    r=[]
    for i in range(10):
      t=[ j  for  j  in  b  if  j % 10 == i ]
      t.sort(reverse=True)
      r+=t
    print(*r)
  except EOFError:
    break