import java.util.Scanner;
public class a255 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()){
int count = input.nextInt();
int [] num = new int [count];
for (int i = 0; i < count; i++){
num[i] = input.nextInt();
}
for (int i = 0; i < count; i++){
for (int j = 0; j < count - 1; j++){
if (num[j] % 10 > num[j + 1] % 10){ //個位數比大小,由小到大
int temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
if (num[j] % 10 == num[j + 1] % 10 && num[j] < num[j + 1]){ //個位數相同,由大到小
int temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
}
}
for (int i : num){
System.out.print(i + " ");
}
System.out.println();
}
input.close();
}
}