Question
Diff Peak

Lila holds an array B of size M. For every pair of indices (p, q) where 1 ≤ p < q ≤ M, compute the maximum absolute difference |Bp - Bq| in the array.

Input
The first line of the input contains a single integer M.
The second line of the input contains M space-separated integers.
Output
Print the maximum value of abs(Bi - Bj) in the array.
Example
Sample Input
5
7 9 4 1 8
Sample Output
8
Explanation
9 is at index 2 and 1 is at index 4, so q > p and 9 - 1 = 8 which is max, hence the answer is 8.

Online