using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO.RInt;
            var A = IO.RSInt;
            //var N = 200000;
            //var A = Enumerable.Repeat(1000000000, N).ToArray();


            Array.Sort(A);
            Array.Reverse(A);

            var Node = new List<int>();
            Node.Add(A[0]);
            Node.Add(A[1]);
            var Edge = new PriorityQueue<int>();
            Edge.Push(Min(A[0], A[1]));
            Edge.Push(Min(A[0], A[1]));
            long ans = Max(A[0], A[1]);
            //ReadLine();

            for (int i = 2; i < N; i++)
            {
                ans += Edge.Top;
                Edge.Pop();
                Edge.Push(A[i]);
                Edge.Push(A[i]);
            }
            WriteLine(ans);
        }
    }

    class PriorityQueue<T>
  where T : IComparable<T>
    {
        #region フィールド

        List<T> buffer;

        #endregion
        #region 初期化

        public PriorityQueue() { this.buffer = new List<T>(); }
        public PriorityQueue(int capacity) { this.buffer = new List<T>(capacity); }

        #endregion
        #region ヒープ操作

        /// <summary>
        /// ヒープ化されている配列リストに新しい要素を追加する。
        /// </summary>
        /// <param name="array">対象の配列リスト</param>
        static void PushHeap(List<T> array, T elem)
        {
            int n = array.Count;
            array.Add(elem);

            while (n != 0)
            {
                int i = (n - 1) / 2;
                if (array[n].CompareTo(array[i]) > 0)
                {
                    T tmp = array[n]; array[n] = array[i]; array[i] = tmp;
                }
                n = i;
            }
        }

        /// <summary>
        /// ヒープから最大値を削除する。
        /// </summary>
        /// <param name="array">対象の配列リスト</param>
        static void PopHeap(List<T> array)
        {
            int n = array.Count - 1;
            array[0] = array[n];
            array.RemoveAt(array.Count - 1);

            for (int i = 0, j; (j = 2 * i + 1) < n;)
            {
                if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) < 0))
                    j++;
                if (array[i].CompareTo(array[j]) < 0)
                {
                    T tmp = array[j]; array[j] = array[i]; array[i] = tmp;
                }
                i = j;
            }
        }

        #endregion
        #region 要素の挿入・削除

        /// <summary>
        /// 要素のプッシュ。
        /// </summary>
        /// <param name="elem">挿入したい要素</param>
        public void Push(T elem)
        {
            PushHeap(this.buffer, elem);
        }

        /// <summary>
        /// 要素を1つポップ。
        /// </summary>
        /// <remarks>
        /// 今回の実装では、先頭要素の読み出しと削除は別に行う。
        /// この Pop では削除のみ。
        /// 読み出しには Top プロパティを使う。
        /// </remarks>
        public void Pop()
        {
            PopHeap(this.buffer);
        }

        /// <summary>
        /// 先頭要素の読み出し。
        /// </summary>
        public T Top
        {
            get { return this.buffer[0]; }
        }

        public int Count
        {
            get { return this.buffer.Count; }
        }

        #endregion
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 44716