You have sticks of various lengths. To connect two sticks, the cost is the sum of their lengths. Connect all sticks into one with minimum cost.
For : connect (cost ), then (cost ). Total cost . Or: (cost ), then (cost ). Total cost . The first way is better.
Constraint: you can only connect two sticks at a time. Each merge produces a new stick whose length is the sum. Order matters: merging small sticks early keeps costs low.