package main import . "fmt" import . "slices" func main() { var n int Scan(&n) a:=make([]int64,n) for i:=range a { Scan(&a[i]) } Sort(a) Reverse(a) var ans int64 for i:=1;len(a)>0;i*=2 { for x:=0;x0;x++ { ans+=a[0] a=a[1:] } } Println(ans) }