#K53762. Maximum Pollution Difference
Maximum Pollution Difference
Maximum Pollution Difference
You are given an integer n and a sequence of n integers representing the pollution levels in various cities. Your task is to calculate the maximum absolute difference between any two pollution levels, which is defined by:
$$\max_{1 \le i \le n}(pollution[i]) - \min_{1 \le i \le n}(pollution[i])$$
Read the input from STDIN and output the result to STDOUT. Make sure your solution works for all provided test cases.
inputFormat
The input is given via STDIN as follows:
- The first line contains a single integer \(n\), which represents the number of cities.
- The second line contains \(n\) space-separated integers, where each integer denotes the pollution level of a city.
outputFormat
Output to STDOUT a single integer representing the maximum absolute difference between the pollution levels, computed as:
$$\max(pollution) - \min(pollution)$$
## sample6
1 2 3 4 5 6
5