You are given an integer array, of size , and an integer . Then you have to perform a total of operations on the array. The operations can be of types. They are:
Operation type 1:
Add to each element of the sub-array . For example, if the current array is , after performing the operation the updated array will be .
Operation type 2:
Find the summation of absolute differences between the adjacent elements of the sub-array . More formally, find the value of . Here, means absolute (non-negative) value of .
The first line contains two space-separated integers and , the size of the array and the number of operations, respectively. The second line contains space-separated integers denoting the array. The integer represents the element, of the array. After that lines follow. The line represents the operation.
Constraints:
In case of operation type , .
Output the answer of each operation type in a separated line.
Input | Output |
---|---|
6 5 1 3 8 5 10 6 2 1 6 1 4 5 3 2 1 3 1 1 2 10 2 2 4 | 19 7 5 |