#C4821. Maximum Difference
Maximum Difference
Maximum Difference
Given a list of n integers, your task is to compute the maximum difference between any two elements from the list. If there is only one element in the list, the maximum difference is 0.
Note: The maximum difference for the list can be simply computed by subtracting the minimum value from the maximum value.
For example, for the list [1, 9, 3, 4, 5], the maximum difference is 9 - 1 = 8
.
inputFormat
The first line of input contains one integer n
(where n ≥ 1
), representing the number of elements in the list. The second line contains n
space-separated integers.
outputFormat
Output a single integer — the maximum difference between any two elements in the list. If n
is 1, output 0
.
5
1 9 3 4 5
8
</p>