# 1441 : MErGe from sys import stdin N,Q=list(map(int,stdin.readline().split())) A=list(map(int,stdin.readline().split())) for _ in range(Q): T,l,r=list(map(int,stdin.readline().split())) l-=1 r-=1 if T==1: A=A[0:l]+[sum(A[l:r+1])]+A[r+1:] else: print(sum(A[l:r+1]))