n,*l=list(map(int,open(0).read().split()));print((sum(sorted(l*2)[-2:~n:-1])))
n,*l=list(map(int,open(0).read().split()))

l.sort(reverse=1)

print((sum(l[i//2] for i in range(1,n))))
n, *l = list(map(int, open(0).read().split()))
print((sum(sorted(l * 2)[-2:~n:-1])))

n, *l = list(map(int, open(0).read().split()))
l.sort(reverse=1)
print((sum(l[i // 2] for i in range(1, n))))

-print((sum(sorted(l * 2)[-2:~n:-1]))) +l.sort(reverse=1) +print((sum(l[i // 2] for i in range(1, n))))