#K65672. Maximum Difference
Maximum Difference
Maximum Difference
You are given an array of integers. Your task is to find the maximum difference between any two elements ai and aj such that j > i. In other words, you need to compute
$$\max_{i<j} \bigl(a_j - a_i\bigr)$$
If no pair exists that satisfies the condition, the answer is 0.
Example:
Input: 6 4 3 10 2 9 1</p>Output: 7
inputFormat
The input is read from standard input (stdin). The first line contains a single integer n which represents the number of elements. The second line contains n space-separated integers.
outputFormat
Output a single integer — the maximum difference between any two elements ai and aj (with j > i). Print the result to standard output (stdout).
## sample6
4 3 10 2 9 1
7