Difficulty Level: MEDIUM
Problem Statement:
You are given N different length ropes. Write an efficient program to connect these ropes into one with minimum cost, such that the cost of connecting two ropes is equal to the sum of their lengths.
Input:
arr[] = { 4, 3, 2, 6 }, N=4
Output:
29