Problems > Widest Gap

Widest Gap

Difficulty: 1100 3000 ms 128 MB

sorting

Sort the values; print the largest difference between consecutive sorted values (0 when N = 1).

Input: the first line has N; the second line has N integers.

Output: the maximum adjacent gap after sorting.

Constraints:

  • 1 ≤ N ≤ 105
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
4
1 7 3 10
Output 1
4
Input 2
1
5
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.