class Solution:
"""
@param sticks: the length of sticks
@return: Minimum Cost to Connect Sticks
"""
def MinimumCost(self, sticks):
# write your code here
import heapq
heapq.heapify(sticks)
ans = 0
while len(sticks) > 1:
x = heapq.heappop(sticks)
y = heapq.heappop(sticks)
ans += x+y
heapq.heappush(sticks,x+y)
return ans