#K67132. Hiking Distance Calculator
Hiking Distance Calculator
Hiking Distance Calculator
You are given a hiking log represented by an array of integers, where each integer denotes the number of kilometers hiked on a specific day. Additionally, you are given a sequence of queries. Each query consists of two integers \(L\) and \(R\) representing the starting and ending days (1-indexed).
Your task is to calculate the total distance hiked for each query. In other words, for each query, compute the sum:
\(\sum_{i=L}^{R} distance[i]\)
where \(distance[i]\) is the distance hiked on the \(i\)-th day.
Input/Output specifications are provided below.
inputFormat
The input is given via standard input (stdin) and has the following format:
- An integer \(N\) representing the number of days.
- \(N\) space-separated integers where the \(i\)-th integer represents the kilometers hiked on the \(i\)-th day.
- An integer \(Q\) denoting the number of queries.
- \(Q\) lines follow, each containing two integers \(L\) and \(R\) (1-indexed) indicating the start and end day for the query.
outputFormat
For each query, output the total kilometers hiked from day \(L\) to day \(R\) on a new line via standard output (stdout).
## sample1
5
1
1 1
5
</p>