#K91977. Warehouse Operations

    ID: 38095 Type: Default 1000ms 256MiB

Warehouse Operations

Warehouse Operations

You are given a warehouse with N boxes numbered from 1 to N. The i-th box contains a certain number of items initially. You need to process a series of operations on these boxes. There are two types of operations:

  • Query (Q l r): Calculate and output the sum of items in boxes numbered from l to r (inclusive).
  • Update (U l r k): Increment the number of items in each box from index l to r (inclusive) by k.

All indices are 1-based. The program should process the operations in the given order and output the result of each query operation on a new line.

The formula for a query operation (if you need a mathematical representation) is given by:

\( S = \sum_{i=l}^{r} a_i \)

where \( a_i \) is the number of items in the i-th box.

inputFormat

The input is given via stdin and has the following format:

  1. The first line contains an integer N, the number of boxes.
  2. The second line contains N space-separated integers representing the initial number of items in each box.
  3. The third line contains an integer M, the number of operations to perform.
  4. The following M lines each describe an operation in one of the following formats:
    • Q l r for a query operation.
    • U l r k for an update operation.

All input values are read from stdin.

outputFormat

For each query operation, output the result (the sum of items in the specified range) on a separate line. All output should be written to stdout.

## sample
5
1 2 3 4 5
3
Q 1 3
U 2 4 2
Q 1 3
6

10

</p>