#C3736. Max Height Difference in Sorted Lineup

    ID: 47196 Type: Default 1000ms 256MiB

Max Height Difference in Sorted Lineup

Max Height Difference in Sorted Lineup

You are given an integer \(N\) representing the number of students and a list of \(N\) integers that denote their heights. The goal is to arrange the students in a non-decreasing order and then determine the maximum height difference between any two adjacent students. Formally, if the sorted heights are \(h_1 \le h_2 \le \dots \le h_N\), you need to compute:

[ \max_{1 \le i < N} {h_{i+1} - h_i} ]

If there is only one student, the maximum difference is defined to be 0.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains a single integer \(N\), representing the number of students.
  • The second line contains \(N\) space-separated integers, where each integer represents the height of a student.

outputFormat

Output a single integer to standard output (stdout) which is the maximum height difference between any two adjacent students after sorting the heights in non-decreasing order.

## sample
5
4 2 3 5 1
1