#K38662. Minimum Construction Cost

    ID: 26249 Type: Default 1000ms 256MiB

Minimum Construction Cost

Minimum Construction Cost

You are given \( n \) skyscrapers with heights represented by an array. The construction cost of creating a portal between two adjacent skyscrapers is defined as the absolute difference of their heights. Formally, if the heights (after sorting) are \( h_1, h_2, \dots, h_n \), then the cost between consecutive skyscrapers is given by \( |h_i - h_{i-1}| \) for \( i = 2, \dots, n \). Your task is to compute the minimum possible construction cost among all such pairs.

inputFormat

The first line contains an integer \( n \) representing the number of skyscrapers. The second line contains \( n \) space-separated integers, each denoting the height of a skyscraper.

outputFormat

Output a single integer representing the minimum possible construction cost.

## sample
3
10 20 30
10

</p>