Beacon towers are built throughout and alongside the Great Wall. There was once a time when there were

beacon towers built from west to east for defending against the invaders. The altitude of the

-th beacon tower, based on historical records, is

.
The defenders strategically divide all beacon towers into

parts where each part contains several, but at least one, consecutive beacon towers. The scale of an individual part is given by the difference between the highest and the lowest altitudes of beacon towers, and the most relaxable partition
minimizes the sum of scales of all parts.
As a historian, you are dying to know the
minimum sums of scales for every

.