#C14260. Maximum-Minimum Difference
Maximum-Minimum Difference
Maximum-Minimum Difference
You are given a list of integers. Your task is to compute the absolute difference between the maximum and the minimum element in the list. In mathematical terms, if \(A\) is the array of numbers, you need to find \(|\max(A) - \min(A)|\). If the list contains fewer than 2 elements, output 0.
inputFormat
The input is given via stdin in the following format:
- The first line contains a single integer \(n\) representing the number of elements in the list.
- If \(n \ge 1\), the second line contains \(n\) space-separated integers.
outputFormat
Output a single integer to stdout which is the absolute difference between the largest and smallest numbers in the list. If the list has less than 2 elements, output 0.
## sample4
3 1 9 7
8