local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end
table.sort(a,function(a,b)
    return a>b
end)

local total=a[1]
for i=3,n do
    total=total+math.max(a[i],a[i-1])
end
print(total)