#t488. 整数序列的元素最大跨度值

整数序列的元素最大跨度值

Maximum Span of an Integer Sequence

Problem Description

Given a non-negative integer sequence of length nn, compute its maximum span (maximum span = largest value minus smallest value).

Input Format

Two lines in total. The first line is the count nn (1≤n≤10001 \le n \le 1000). The second line contains the nn non-negative integers of the sequence, not exceeding 10001000, separated by single spaces.

Output Format

One line: the maximum span of the sequence.

Sample Input

6
3 0 8 7 5 9

Sample Output

9

Constraints

1≤n≤10001 \le n \le 1000; each value ≤1000\le 1000.

Hint

  • Just track the running minimum and maximum while reading the numbers, then print max - min.