Problem Summary
There are N piles of stones in a row. The i-th pile has Xi stones.
A move consists of merging exactly K consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these K piles.
Find the minimum cost to merge all piles of stones into one pile. If impossible, return -1.