#K67362. Maximum Difference Subsequence

    ID: 32626 Type: Default 1000ms 256MiB

Maximum Difference Subsequence

Maximum Difference Subsequence

You are given a sequence of integers. Your task is to compute the maximum absolute difference between any two elements in the sequence. In other words, you need to find the maximum value of \(|a - b|\) for any two elements \(a\) and \(b\) in the sequence.

This can be achieved by simply determining the minimum and maximum values in the sequence and then computing their difference. Formally, if the sequence is represented as \(a_1, a_2, \dots, a_n\), the answer can be computed as:

[ \text{result} = \max_{1 \leq i \leq n} a_i - \min_{1 \leq i \leq n} a_i ]

If the sequence consists of a single element, the maximum difference is \(0\).

inputFormat

The first line contains an integer \(n\) representing the number of elements in the sequence. The second line contains \(n\) space-separated integers which constitute the sequence.

outputFormat

Output a single integer: the maximum absolute difference between any two elements in the sequence.

## sample
5
1 2 9 4 5
8

</p>