object Solution { def main(args: Array[String]) { val sc = new java.util.Scanner (System.in); var n = sc.nextInt(); var calories = new Array[Int](n); for(calories_i <- 0 to n-1) { calories(calories_i) = sc.nextInt(); } // your code goes here calories = calories.sorted.reverse; var sum:Long = 0; var mul:Long = 1; for(i<- 0 to n - 1) { sum += (mul * calories(i)) mul *= 2 } println(sum) } }