#K36102. Minimize Maximum Adjacent Difference

    ID: 25680 Type: Default 1000ms 256MiB

Minimize Maximum Adjacent Difference

Minimize Maximum Adjacent Difference

Elena is participating in a sports tournament, where she must complete N obstacle courses with varying difficulty levels. You are given a list of N integers representing these difficulty levels. Your task is to reorder the courses such that the maximum difference between any two consecutive courses is minimized.

Formally, if the reordered difficulties are denoted as \(a_1, a_2, \dots, a_N\), you need to minimize \[ \max_{1 \le i < N} \left|a_{i+1} - a_i\right| \] and output that minimum value.

Note: You have to output only the minimized maximum difference.

inputFormat

The first line contains an integer N (\(2 \le N \le 10^5\)), representing the number of courses.

The second line contains N space-separated integers, where each integer represents the difficulty of a course.

outputFormat

Output a single integer representing the minimal possible maximum difference between consecutive courses after an optimal reordering.

## sample
5
4 2 9 7 5
2