#K89427. Merkle Tree Root Computation
Merkle Tree Root Computation
Merkle Tree Root Computation
You are given a sequence of data blocks and a set of range queries. For each query, you need to compute the Merkle tree root for the given range. In this problem, the Merkle tree root is defined as the sum of the data blocks in the query range. More formally, given an array \(a_1, a_2, \dots, a_n\) and a query \((l, r)\), you must output:
\(\text{result} = \sum_{i=l}^{r} a_i\)
Note: The array is 1-indexed.
inputFormat
The input is given in the following format:
- The first line contains a single integer \(n\) representing the number of data blocks.
- The second line contains \(n\) space-separated integers representing the data blocks.
- The third line contains a single integer \(q\) representing the number of queries.
- The following \(q\) lines each contain two space-separated integers \(l\) and \(r\), indicating a query for the sum of elements from index \(l\) to \(r\) (inclusive).
outputFormat
For each query, output a single line containing the computed Merkle tree root (i.e., the sum of the range) in the same order as the queries.
## sample1
5
1
1 1
5
</p>