You are given an array of integers of size n. You need to implement a data structure that can perform the following operations:
1)Add to all numbers on the segment [l;r] the value d.
2)Get the sum of numbers on the segment [l;r].
3)Get the minimum from the numbers on the segment [l;r].
INPUT
The input comes with the number n – the size of the array. The next line contains n numbers separated by a space - ai.
Next, the number m is given - the number of requests. In the next m lines, there are three types of requests:
1)add l r d - adding the number d on the segment [l;r].
3)rsq l r - request for the sum on the segment [l;r].
3)rmq l r - request for the minimum on the segment [l;r].
OUTPUT
Responses for requests of the second and third types separated by a space.
P.S. 0 < n, m < 100001 ai < 1000000001.
P.S.S. The response is guaranteed to fit into a 64-bit data type.
INPUT
5
1 2 3 4 5
3
rsq 1 5
add 2 3 1
rmq2 4
OUTPUT
15 3
(c) Nikita Maksimov, 2017