#K41737. Total Travel Time Calculation
Total Travel Time Calculation
Total Travel Time Calculation
You are given a transit system with ( N ) stations and a list of travel times between consecutive stations. The travel time between station ( i ) and station ( i+1 ) is given by ( t_i ). Given two stations, ( S ) and ( E ) (with ( 1 \leq S < E \leq N )), compute the total travel time from station ( S ) to station ( E ) using the formula
( T = \sum_{i=S}^{E-1} t_i )
Note that all station indices are 1-indexed.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
1. The first line contains a single integer ( N ) representing the number of stations.
2. The second line contains ( N-1 ) space-separated integers, where the ( i^{th} ) integer is the travel time ( t_i ) between station ( i ) and station ( i+1 ).
3. The third line contains two space-separated integers ( S ) and ( E ), representing the starting station and the ending station respectively.
It is guaranteed that ( 1 \leq S < E \leq N ).
outputFormat
Output a single integer to standard output (stdout) representing the total travel time from station ( S ) to station ( E ).## sample
5
10 15 20 25
2 4
35