mport Control.Applicative
import Control.Monad
import Data.Array.IO

type Query = IOUArray Int Int -> IO (IOUArray Int Int)

--main = do
--        [n,q] <- map read.words<$>getLine
--        qs    <- replicateM q $ inpToQuerys.map read.words<$>getLine
--        foldl (>>=) (newArray (1,n) 0) qs
--        return ()

main = do
        [n,q] <- map read.words<$>getLine
        arr <- newArray (1,n) 0
        command q 1 arr

command end current arr
    | end < current = return ()
    | otherwise = do
        q <- inpToQuerys.map read.words<$>getLine
        q arr >>= command end (current+1)

inpToQuerys :: [Int] -> Query
inpToQuerys [c,x,y]
    | c == 0 = add x y
    | c == 1 = getSum x y

modifyArray arr ix f = readArray arr ix >>= \e -> writeArray arr ix (f e) >> return arr

add :: Int -> Int -> Query
add i x = \arr -> modifyArray arr i (+ x)

getSum :: Int -> Int -> Query
getSum x y= \arr -> gs 0 y x arr >> return arr

gs :: Int -> Int -> Int -> Query
gs acc stop i arr
    | stop == i = readArray arr i >>= \e -> print (acc + e) >> return arr
    | otherwise = do
        e <- readArray arr i
        gs (acc+e) stop (i+1) arr