CF1108E1 Array and Segments (Easy version)

Description

The only difference between easy and hard versions is a number of elements in the array. You are given an array $ a $ consisting of $ n $ integers. The value of the $ i $ -th element of the array is $ a_i $ . You are also given a set of $ m $ segments. The $ j $ -th segment is $ [l_j; r_j] $ , where $ 1 \le l_j \le r_j \le n $ . You can choose some subset of the given set of segments and decrease values on each of the chosen segments by one (independently). For example, if the initial array $ a = [0, 0, 0, 0, 0] $ and the given segments are $ [1; 3] $ and $ [2; 4] $ then you can choose both of them and the array will become $ b = [-1, -2, -2, -1, 0] $ . You have to choose some subset of the given segments (each segment can be chosen at most once) in such a way that if you apply this subset of segments to the array $ a $ and obtain the array $ b $ then the value $ \max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i $ will be maximum possible. Note that you can choose the empty set. If there are multiple answers, you can print any. If you are Python programmer, consider using PyPy instead of Python when you submit your code.

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first example the obtained array $ b $ will be $ [0, -4, 1, 1, 2] $ so the answer is $ 6 $ . In the second example the obtained array $ b $ will be $ [2, -3, 1, -1, 4] $ so the answer is $ 7 $ . In the third example you cannot do anything so the answer is $ 0 $ .