#K64967. Maximum Gap Between Sorted Publication Years

    ID: 32093 Type: Default 1000ms 256MiB

Maximum Gap Between Sorted Publication Years

Maximum Gap Between Sorted Publication Years

Given a list of publication years, your task is to find the maximum gap between any two consecutive years after sorting the list in increasing order.

Formally, for a given list of integers (A = [a_1, a_2, \ldots, a_n]) where (n \ge 1), after sorting the list in non-decreasing order, the maximum gap is defined as (\max_{2\le i\le n}(a_i - a_{i-1})). If the list has fewer than 2 elements, the answer is 0.

Note: If all years are identical, the maximum gap is 0.

You are required to read input from standard input and write the result to standard output. The input starts with an integer (n) (the number of years), followed by a line with (n) space-separated integers representing the publication years.

inputFormat

The input consists of two lines. The first line contains an integer (n), which is the number of publication years. The second line contains (n) space-separated integers representing the publication years.

outputFormat

Output a single integer that is the maximum gap between two consecutive years after sorting the list.## sample

4
1995 1983 2020 2010
15