fork download
  1. pref = [0]
  2. _ = input()
  3. for liczba in map(int, input().split()):
  4. pref.append(pref[-1]+liczba)
  5. print(pref)
  6. test = int(input())
  7. for i in range(test):
  8. a,b = map(int, input().split())
  9. print(pref[b]-pref[a-1])
  10.  
Success #stdin #stdout 0.02s 9784KB
stdin
5
2 3 7 8 1
2
2 4
1 5
stdout
[0, 2, 5, 12, 20, 21]
18
21