Counting Haybales#11165

Counting Haybales

1 second
128 megabytes
Easy

Farmer John's farm consists of fields arranged in a row, conveniently numbered . Each field can contain any number of haybales. Farmer John's instructions contain three types of operations:

  1. Given a contiguous interval of fields, add a specified number of new haybales to each field in the interval.

  2. Given a contiguous interval of fields, determine the minimum number of haybales in any field within that interval.

  3. Given a contiguous interval of fields, determine the total number of haybales in all fields within that interval.

Input

The first line contains two positive integers n~(1 \le n \le 2 \cdot 10^5) and q~(1 \le q \le 10^5).

The next line contains nonnegative integers, each at most 10^5, indicating the initial number of haybales in each field.

Each of the next lines contains a single uppercase letter, either , , or , followed by either two positive integers and (1 \le a \le b \le n), or three positive integers , , and (1 \le a \le b \le n, 1 \le c \le 10^5). There will be three positive integers if and only if the uppercase letter is .

If the letter is , print the minimum number of haybales in the interval of fields from .

If the letter is , add new haybales to each field in the interval of fields from .

If the letter is , print the total number of haybales in the interval of fields from .

Output

For each or operation in FJ's instructions, output one line containing the answer to that operation.

Examples

Example 1

Loading
Loading