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

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

modifyArray arr i f = do
  e <- readArray arr i
  writeArray arr i (f e)

add :: Int -> Int -> Int -> StateT (IOArray Int Int) IO ()
add s t x = do
  arr <- get
  forM_ [s..t] $ \i -> liftIO $ modifyArray arr i (+x)

get' :: Int -> StateT (IOArray Int Int) IO Int
get' i = get >>= \arr -> liftIO $ readArray arr i

query :: String -> StateT (IOArray Int Int) IO ()
query (c:cs)
  | c == '0' = add s' t' x'
  | c == '1' = get' i >>= \x -> liftIO (print x)
  where [s',t',x'] = map read.words $ cs
        i          = head.map read.words $ cs