#Q6. 「一本通 1.1 练习 1」数列极差
「一本通 1.1 练习 1」数列极差
Description
Jiajia's teacher wrote a sequence of positive integers on the blackboard and asked Jiajia to perform the following operation: each time, erase two numbers and , then add a number to the sequence. Repeat this process until only one number remains. Among all the numbers obtained in this way, the largest is denoted as , the smallest as , and the range of the sequence is defined as .
Since Jiajia is busy preparing for final exams, please help him calculate the corresponding range for the given sequence.
Input Format
The first line contains a positive integer indicating the length of the positive integer sequence.
The next lines each contain a positive integer.
A line with a single follows, indicating the end of the data.
Output Format
Output consists of a single line, the corresponding range .
Sample 1
3
1
2
3
0
2
Data Range and Hint
For all data, , and it is guaranteed that all calculations fit within the range of a 32-bit signed integer.