#include <iostream>
#include <algorithm>
using namespace std;
 
// 计算一个数的数字和
int digitSum(int num) {
    int sum = 0;
    while (num > 0) {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}
 
int main() {
    int n;
    cin >> n;
    int nums[10];
    int digitSums[10];
 
    // 读取 n 个整数并计算数字和
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
        digitSums[i] = digitSum(nums[i]);
    }
 
    // 对数字和进行排序
    sort(digitSums, digitSums + n);
 
    // 输出排序后的数字和
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << digitSums[i];
    }
    cout << endl;
 
    return 0;
}    
/**************************************************************
	Problem: 1166
	User: linmiaoling
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2076 kb
****************************************************************/