#C8061. Maximum Score Difference
Maximum Score Difference
Maximum Score Difference
You are given an array of integers representing scores. Your task is to compute the maximum difference (\Delta = s_j - s_i) such that (s_j > s_i) and the index (i < j). If no such pair exists, output (-1).
In other words, if the array is (s_1, s_2, \dots, s_n), find the maximum value of (s_j - s_i) where (1 \leq i < j \leq n) and (s_i < s_j). The array will be provided via standard input and your program should write the result to standard output.
inputFormat
The input is given via standard input (stdin). The first line contains a single integer \(n\), the number of scores. The second line contains \(n\) space-separated integers representing the scores.
outputFormat
Output a single integer which is the maximum score difference as described above. If no valid pair exists such that a later score is greater than an earlier score, output \(-1\).
## sample6
1 2 90 10 110 5
109
</p>