#STSC1A. [STSC OI - 1A] 加和 (sum)

[STSC OI - 1A] 加和 (sum)

Background

This problem is an exercise on prefix sums. Please solve this problem using prefix sums.

Please use C++, and use scanf() instead of std::cin.

Description

Given an integer sequence, find the sum from the ll-th term to the rr-th term.

Input

The input consists of 33 lines:

  • Line 1: A positive integer nn, the length of the integer sequence.
  • Line 2: nn integers a1,a2,,ana_1, a_2, \cdots, a_n, representing the integer sequence.
  • Line 3: Two positive integers ll and rr, indicating that we require the sum from the ll-th to the rr-th term.

Output

Output one line with a single integer ss, the sum from the ll-th to the rr-th term in the integer sequence.

6
178 24 16 -19 52 1
2 4
21

Hint

For test cases #1 to #10, it is guaranteed that 1n60001 \le n \le 6000, 105ai105-10^5 \le a_i \le 10^5, and 1lrn1 \le l \le r \le n.

For test case #11, n=106n = 10^6 and 105ai105-10^5 \le a_i \le 10^5.