a,b=map(int,input().split()) c=list(map(int,input().split())) for i in range(b): d,e,f=map(int,input().split()) print(sum(c[d-1:e]))