#C2044. Largest Gap

    ID: 45317 Type: Default 1000ms 256MiB

Largest Gap

Largest Gap

You are given an integer \(n\) and an array of \(n\) integers. Your task is to find the largest gap between any two consecutive elements after sorting the array in non-decreasing order. Formally, if the sorted sequence is \(a_1, a_2, \ldots, a_n\), then the answer is given by:

\(\max_{2 \leq i \leq n} (a_i - a_{i-1})\)

If all elements are identical, the answer is \(0\).

inputFormat

The input consists of two lines:

  • The first line contains an integer \(n (n \geq 2)\) denoting the number of elements in the array.
  • The second line contains \(n\) space-separated integers.

outputFormat

Output a single integer representing the largest gap between any two consecutive elements in the sorted order.

## sample
5
1 2 3 4 5
1

</p>