CodeEff/ECCO huggingface dataset:
# Original solution
class FenwickTree():
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def add(self, p, x):
        #assert 0 <= p < self.n
        p += 1
        while p <= self.n:
            self.data[p - 1] += x
            p += p & -p

    def sum(self, r):
        s = 0
        while r:
            s += self.data[r - 1]
            r -= r & -r
        return s

    def range_sum(self, l, r):
        #assert 0 <= l <= r <= self.n
        return self.sum(r) - self.sum(l)

import sys
input = sys.stdin.buffer.readline

N, Q = list(map(int, input().split()))
A = tuple(map(int, input().split()))

ft = FenwickTree(N)
res = []

for i, a in enumerate(A):
    ft.add(i, a)

for _ in range(Q):
    q, x, y = list(map(int, input().split()))
    if q:
        res.append(str(ft.range_sum(x, y)))

    else:
        ft.add(x, y)

print(('\n'.join(res)))

# Optimized solution
class FenwickTree():
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def build(self, arr):
        #assert len(arr) <= n
        for i, a in enumerate(arr):
            self.data[i] = a
        for i in range(1, self.n + 1):
            if i + (i & -i) <= self.n:
                self.data[i + (i & -i) - 1] += self.data[i - 1]

    def add(self, p, x):
        #assert 0 <= p < self.n
        p += 1
        while p <= self.n:
            self.data[p - 1] += x
            p += p & -p

    def sum(self, r):
        s = 0
        while r:
            s += self.data[r - 1]
            r -= r & -r
        return s

    def range_sum(self, l, r):
        #assert 0 <= l <= r <= self.n
        return self.sum(r) - self.sum(l)

import sys
input = sys.stdin.buffer.readline

N, Q = list(map(int, input().split()))
A = tuple(map(int, input().split()))

ft = FenwickTree(N)
ft.build(A)
res = []

for _ in range(Q):
    q, x, y = list(map(int, input().split()))
    if q:
        res.append(str(ft.range_sum(x, y)))
    else:
        ft.add(x, y)

print(('\n'.join(res)))
# Original solution
import sys
input = lambda: sys.stdin.readline().rstrip()

class BIT:
  def __init__(self, n):
    self.bit = [0] * n

  def add(self, i, x):
    i += 1
    while i <= len(self.bit):
      self.bit[i-1] += x
      i += i & -i

  def sum_sub(self, i):
    a = 0
    i += 1
    while i:
      a += self.bit[i-1]
      i -= i & -i
    return a

  def sum(self, i, j):
    a = 0
    if j != 0:
      a += self.sum_sub(j-1)
    if i != 0:
      a -= self.sum_sub(i-1)
    return a

n,q=list(map(int,input().split()))
a=list(map(int,input().split()))
Bit=BIT(n)
for i in range(n):
  Bit.add(i,a[i])
for i in range(q):
  t,a,b=list(map(int,input().split()))
  if t==0:
    Bit.add(a,b)
  else:
    print((Bit.sum(a,b)))

# Optimized solution
import sys
input = sys.stdin.readline


class BIT():
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s


n,q=list(map(int,input().split()))
a=list(map(int,input().split()))
bit=BIT(n,a)
for i in range(q):
    t,x,y=list(map(int,input().split()))
    if t==0:
        bit.add(x+1,y)
    else:
        print((bit.sum(y)-bit.sum(x)))
# Original solution
import sys
input = sys.stdin.readline


class BIT():
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s


n,q=list(map(int,input().split()))
a=list(map(int,input().split()))
bit=BIT(n,a)
for i in range(q):
    t,x,y=list(map(int,input().split()))
    if t==0:
        bit.add(x+1,y)
    else:
        print((bit.sum(y)-bit.sum(x)))

# Optimized solution
from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))

class BIT():
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s


#n,q=map(int,input().split())
#a=list(map(int,input().split()))
n,q=nii()
a=lnii()
bit=BIT(n,a)
for i in range(q):
#    t,x,y=map(int,input().split())
    t,x,y=nii()
    if t==0:
        bit.add(x+1,y)
    else:
        print((bit.sum(y)-bit.sum(x)))
# Original solution
#!/usr/bin python3
# -*- coding: utf-8 -*-

# Binary Indexed Tree
# 1-indexed
# sum(r)        :閉区間 [0,r] の合計を取得する
# [8] a0 ・ a1  ・ a2 ・ a3 ・ a4 ・ a5 ・ a6 ・ a7
# [4] a0 ・ a1  ・ a2 ・ a3
# [2] a0 ・ a1               [6] a4 ・ a5
# [1] a0       [3] a2        [5] a4        [7] a6

#                   [1000]
#           [0100]
#   [0010]                [0110]
# [0001]    [0011]      [0111]      [1111]

class BinaryIndexedTree:
    # 初期化処理
    def __init__(self, size):
        self.size = size
        self.dat = [0]*(size+1)

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.dat[i] += x
            i += i & -i # 更新すべき位置

    def sum(self, r):
        r += 1
        ret = 0
        while r>0:
            ret += self.dat[r]
            r -= r & -r # 加算すべき位置
        return ret

    def init(self, a):
        for i, x in enumerate(a):
            self.add(i, x)

    def initrng(self, a):
        self.add(0, a[0])
        for i in range(1,n):
            self.add(i, a[i]-a[i-1])

n, q = list(map(int,input().split()))
a = list(map(int, input().split()))

bit = BinaryIndexedTree(n)

bit.init(a)
ret = [bit.sum(i) for i in range(n)]
for _ in range(q):
    t, u, v = list(map(int, input().split()))
    if t == 0:
        bit.add(u, v)
    else:
        print((bit.sum(v-1)-bit.sum(u-1)))


# Optimized solution
#!/usr/bin python3
# -*- coding: utf-8 -*-

# Binary Indexed Tree
# 1-indexed
# sum(r)        :閉区間 [0,r] の合計を取得する
# [8] a0 ・ a1  ・ a2 ・ a3 ・ a4 ・ a5 ・ a6 ・ a7
# [4] a0 ・ a1  ・ a2 ・ a3
# [2] a0 ・ a1               [6] a4 ・ a5
# [1] a0       [3] a2        [5] a4        [7] a6

#                   [1000]
#           [0100]
#   [0010]                [0110]
# [0001]    [0011]      [0111]      [1111]

class BinaryIndexedTree:
    # 初期化処理
    def __init__(self, size):
        self.size = size
        self.dat = [0]*(size+1)

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.dat[i] += x
            i += i & -i # 更新すべき位置

    def sum(self, r):
        r += 1
        ret = 0
        while r>0:
            ret += self.dat[r]
            r -= r & -r # 加算すべき位置
        return ret

    def init(self, a):
        for i, x in enumerate(a):
            self.add(i, x)

    def initrng(self, a):
        self.add(0, a[0])
        for i in range(1,n):
            self.add(i, a[i]-a[i-1])

n, q = list(map(int,input().split()))
a = list(map(int, input().split()))
bit = BinaryIndexedTree(n)
bit.init(a)
for _ in range(q):
    t, u, v = list(map(int, input().split()))
    if t == 0:
        bit.add(u, v)
    else:
        print((bit.sum(v-1)-bit.sum(u-1)))
# Original solution
n, q = list(map(int, input().split()))
lst = [int(i) for i in input().split()]
sum_list = [0]
total = 0
for i in range(n):
  total += lst[i]
  sum_list.append(total)
for _ in range(q):
  t, a, b = list(map(int, input().split()))
  if t == 0:
    for i in range(a + 1, n + 1):
      sum_list[i] += b
  else:
    print((sum_list[b] - sum_list[a]))
    

# Optimized solution
class bit:
  def __init__(self, n):
    self.size = n
    self.bit = [0] * (n + 1)
  
  def make(self, lst):
    self.bit = [0] + lst[:]
    for i in range(1, self.size + 1):
      if i + (i & -i) > self.size:
        continue
      self.bit[i + (i & -i)] += self.bit[i]
  
  def add(self, a, b):
    i = a + 1
    while i <= self.size:
      self.bit[i] += b
      i += i & -i
  
  def sum(self, a):
    i = a
    ret = 0
    while i > 0:
      ret += self.bit[i]
      i -= i & -i
    return ret
  
  def sub(self, a, b):
    return self.sum(b) - self.sum(a)

n, q = list(map(int, input().split()))
lst = [int(i) for i in input().split()]
l = bit(n)
l.make(lst)
for _ in range(q):
  t, a, b = list(map(int, input().split()))
  if t == 0:
    l.add(a, b)
  else:
    print((l.sub(a, b)))
# Original solution
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i - 1]
            i &= i - 1
        return s

    def update(self, i, x):
        while i < self.n:
            self.data[i] += x
            i |= i + 1
        return


n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
b = BIT(n)
for i in range(n):
    b.update(i, c[i])

for i in range(m):
    t, x, y = list(map(int, input().split()))
    if t == 1:
        print((b.sum(y) - b.sum(x)))
    else:
        b.update(x, y)


# Optimized solution
import sys
input = lambda: sys.stdin.readline()

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i - 1]
            i &= i - 1
        return s

    def update(self, i, x):
        while i < self.n:
            self.data[i] += x
            i |= i + 1
        return


n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
b = BIT(n)
for i in range(n):
    b.update(i, c[i])

res = []
for i in range(m):
    t, x, y = list(map(int, input().split()))
    if t == 1:
        res.append(b.sum(y) - b.sum(x))
    else:
        b.update(x, y)
print(("\n".join(map(str, res))))
# Original solution
import sys
input = lambda: sys.stdin.readline()

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i - 1]
            i &= i - 1
        return s

    def update(self, i, x):
        while i < self.n:
            self.data[i] += x
            i |= i + 1
        return


n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
b = BIT(n)
for i in range(n):
    b.update(i, c[i])

res = []
for i in range(m):
    t, x, y = list(map(int, input().split()))
    if t == 1:
        res.append(b.sum(y) - b.sum(x))
    else:
        b.update(x, y)
print(("\n".join(map(str, res))))


# Optimized solution
import sys
input = lambda: sys.stdin.readline()


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i


n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
b = BIT(n)
for i in range(n):
    b.add(i + 1, c[i])

res = []
for i in range(m):
    t, x, y = list(map(int, input().split()))
    if t == 1:
        res.append(b.sum(y) - b.sum(x))
    else:
        b.add(x + 1, y)
print(("\n".join(map(str, res))))
# Original solution
import sys
input = sys.stdin.readline

class segtree:
    x_unit=0 # 単位元
    x_func=sum  # 関数
    def __init__(self,n,seq):
        self.n=n
        self.x=[self.x_unit]*(2*n)
        for i,j in enumerate(seq, self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func([self.x[i*2], self.x[i*2+1]])
    def update(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func([self.x[i*2], self.x[i*2+1]])
    def fold(self,l,r): # 区間[l, r)の合計を取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func([val_l,self.x[l]])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func([val_r,self.x[r]])
            l //= 2
            r //= 2
        return self.x_func([val_l,val_r])

n,q=list(map(int,input().split()))
*a,=list(map(int,input().split()))
seg=segtree(n,a) 
for i in range(q):
    t,x,y=list(map(int,input().split()))
    if t==0:
        old=seg.fold(x,x+1)
        seg.update(x, old+y)
    else:
        print((seg.fold(x, y)))

# Optimized solution
import sys
input = sys.stdin.readline

class segtree:
    x_unit=0 # 単位元
    x_func=lambda self,a:a[0]+a[1]  # 関数
    def __init__(self,n,seq):
        self.n=n
        self.x=[self.x_unit]*(2*n)
        for i,j in enumerate(seq, self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func([self.x[i*2], self.x[i*2+1]])
    def update(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func([self.x[i*2], self.x[i*2+1]])
    def fold(self,l,r): # 区間[l, r)の合計を取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func([val_l,self.x[l]])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func([val_r,self.x[r]])
            l //= 2
            r //= 2
        return self.x_func([val_l,val_r])

n,q=list(map(int,input().split()))
*a,=list(map(int,input().split()))
seg=segtree(n,a) 
for i in range(q):
    t,x,y=list(map(int,input().split()))
    if t==0:
        old=seg.fold(x,x+1)
        seg.update(x, old+y)
    else:
        print((seg.fold(x, y)))
# Original solution
import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))

BIT=[0]*n
def ADD(x,y):#A[x]+=y,1-origin
	while x<=n:
		BIT[x-1]+=y
		x+=x&(-x)
def SUM(l):#1からlまでの和
	if l==0:
		return 0
	ret=0
	while l>=1:
		ret+=BIT[l-1]
		l-=l&(-l)
	return ret

IN=list(map(int,input().split()))
for i in range(n):
	ADD(i+1,IN[i])

for i in range(q):
	t,a,b=list(map(int,input().split()))
	if t==0:
		ADD(a+1,b)
	else:
		print((SUM(b)-SUM(a)))

# Optimized solution
import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))

BIT=[0]*n
def ADD(x,y):#A[x]+=y,1-origin
	while x<=n:
		BIT[x-1]+=y
		x+=x&(-x)
def SUM(l):#1からlまでの和
	ret=0
	while l>=1:
		ret+=BIT[l-1]
		l-=l&(-l)
	return ret

IN=list(map(int,input().split()))
for i in range(n):
	ADD(i+1,IN[i])

for i in range(q):
	t,a,b=list(map(int,input().split()))
	if t==0:
		ADD(a+1,b)
	else:
		print((SUM(b)-SUM(a)))
# Original solution
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
 
    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s
    # 0 index を 1 index に変更  転倒数を求めるなら1を足していく
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # 総和がx以上になる位置のindex をbinary search
    def bsearch(self,x):
        le = 0
        ri = 1<<(self.size.bit_length()-1)
        while ri > 0:
            if le+ri <= self.size and self.tree[le+ri]<x:
                x -= self.tree[le+ri]
                le += ri
            ri >>= 1
        return le+1

n,q = list(map(int,input().split()))
a = list(map(int,input().split()))
bit = BIT(n)
for i,x in enumerate(a):
    bit.add(i,x)
for i in range(q):
    t,l,r = list(map(int,input().split()))
    if t == 0:
        bit.add(l,r)
    else:
        print((bit.sum(r)-bit.sum(l)))

# Optimized solution
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
    
    def make(self, list):
        self.tree[1:] = list.copy()
        for i in range(self.size+1):
            j = i + (i & (-i))
            if j < self.size+1:
                self.tree[j] += self.tree[i]
 
    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s
    # 0 index を 1 index に変更  転倒数を求めるなら1を足していく
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # 総和がx以上になる位置のindex をbinary search
    def bsearch(self,x):
        le = 0
        ri = 1<<(self.size.bit_length()-1)
        while ri > 0:
            if le+ri <= self.size and self.tree[le+ri]<x:
                x -= self.tree[le+ri]
                le += ri
            ri >>= 1
        return le+1

n,q = list(map(int,input().split()))
a = list(map(int,input().split()))
bit = BIT(n)
bit.make(a)
for i in range(q):
    t,l,r = list(map(int,input().split()))
    if t == 0:
        bit.add(l,r)
    else:
        print((bit.sum(r)-bit.sum(l)))
# Original solution
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
    
    def make(self, list):
        self.tree[1:] = list.copy()
        for i in range(self.size+1):
            j = i + (i & (-i))
            if j < self.size+1:
                self.tree[j] += self.tree[i]
 
    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s
    # 0 index を 1 index に変更  転倒数を求めるなら1を足していく
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # 総和がx以上になる位置のindex をbinary search
    def bsearch(self,x):
        le = 0
        ri = 1<<(self.size.bit_length()-1)
        while ri > 0:
            if le+ri <= self.size and self.tree[le+ri]<x:
                x -= self.tree[le+ri]
                le += ri
            ri >>= 1
        return le+1

n,q = list(map(int,input().split()))
a = list(map(int,input().split()))
bit = BIT(n)
bit.make(a)
for i in range(q):
    t,l,r = list(map(int,input().split()))
    if t == 0:
        bit.add(l,r)
    else:
        print((bit.sum(r)-bit.sum(l)))

# Optimized solution
import sys
input = sys.stdin.readline
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
    
    def make(self, list):
        self.tree[1:] = list.copy()
        for i in range(self.size+1):
            j = i + (i & (-i))
            if j < self.size+1:
                self.tree[j] += self.tree[i]
 
    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s
    # 0 index を 1 index に変更  転倒数を求めるなら1を足していく
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # 総和がx以上になる位置のindex をbinary search
    def bsearch(self,x):
        le = 0
        ri = 1<<(self.size.bit_length()-1)
        while ri > 0:
            if le+ri <= self.size and self.tree[le+ri]<x:
                x -= self.tree[le+ri]
                le += ri
            ri >>= 1
        return le+1

n,q = list(map(int,input().split()))
a = list(map(int,input().split()))
bit = BIT(n)
bit.make(a)
for i in range(q):
    t,l,r = list(map(int,input().split()))
    if t == 0:
        bit.add(l,r)
    else:
        print((bit.sum(r)-bit.sum(l)))
# Original solution
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq

class FenwickTree():
    def __init__(self,n):
        self.n = n
        self.tree = [0]*(n+1)
    def add(self,idx,a):#値の更新
        idx+=1
        while idx<=self.n:
            self.tree[idx] +=a
            idx += idx &-idx

    def _sum(self,r):
        ret=0
        r+=1
        while r>0:
            ret+=self.tree[r]
            r-=r&-r
        return ret
    def sum(self,l,r):
        return self._sum(r)-self._sum(l-1)

n,q = ma()
A = lma()
ft = FenwickTree(n)
for i in range(n):
    ft.add(i,A[i])
for i in range(q):
    t,u,v = ma()
    if t==0:
        ft.add(u,v)
    else:
        print(ft.sum(u,v-1))


# Optimized solution
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
input=sys.stdin.readline
class FenwickTree():
    def __init__(self,n):
        self.n = n
        self.tree = [0]*(n+1)
    def add(self,idx,a):#値の更新
        idx+=1
        while idx<=self.n:
            self.tree[idx] +=a
            idx += idx &-idx

    def _sum(self,r):
        ret=0
        r+=1
        while r>0:
            ret+=self.tree[r]
            r-=r&-r
        return ret
    def sum(self,l,r):
        return self._sum(r)-self._sum(l-1)

n,q = ma()
A = lma()
ft = FenwickTree(n)
for i in range(n):
    ft.add(i,A[i])
for i in range(q):
    t,u,v = ma()
    if t==0:
        ft.add(u,v)
    else:
        print(ft.sum(u,v-1))