Error - CSUMQ (SPOJ)

Problem Link - https://www.spoj.com/problems/CSUMQ/
My Code - https://pastebin.com/qCkv1HN0

My code isn’t passing sample test case. Can someone tell me what is wrong in my code logic, and how I can correct it?

You have to read N, then the array and then Q. But in your code, you had read N and then Q.

Oh okay, thanks !