Problems > Range of an Array

Range of an Array

Difficulty: 800 2000 ms 128 MB

implementation

The range of a list is the difference between its largest and smallest value. Print the range of the given list.

Input: the first line has an integer N; the second line has N integers separated by spaces.

Output: one integer — max − min.

Constraints:

  • 1 ≤ N ≤ 2000
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
4
7 2 9 4
Output 1
7
Input 2
1
100
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.