using System;

namespace ConsoleApp25
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            int[,] N = new int[n, 1];
            double br = 0;
            for (int i = 0; i < n; i++)
            {
                N[i, 0] = int.Parse(s[i]);
            }
                for (int o = 0; o < n; o++)
                {
                    int mc = N[o, 0];
                    int i = o;
                    for (int j = o; j < n; j++)
                    {
                        if (mc < N[j, 0])
                        {
                            mc = N[j, 0];
                            i = j;
                        }
                    }
                    if (N[o, 0] < mc)
                    {
                        int a = N[o, 0];
                        N[o, 0] = mc;
                        N[i, 0] = a;
                    }
                }
            
            int y = 0;
            for (int i = n - 1; i >= 0; i--)
            {
                int m = 1;
                int mnoz;
                for (int j = 0; j < i; j++)
                {
                    m *= 10;
                }
                mnoz = m * N[y, 0];
                y++;
                br += mnoz;
            }
            Console.WriteLine(br);

        }
    }
}