import Control.Monad

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  ts <- getInts
  m <- (read :: String -> Int) <$> getLine
  ps <- replicateM m getInts
  --mapM_ print ps
  mapM_ print $ solve (map toPair ps) ts


getInts :: IO [Int]
getInts = map read . words <$> getLine

toPair :: [Int] ->  (Int, Int)
toPair (a:b) = (a, head b)
toPair [] = (0, 0)

solve :: [(Int, Int)] -> [Int] -> [Int]
solve ps ts = map f ps
  where
    f :: (Int, Int) -> Int
    f (a, b) = sum . concat $ [take (a - 1) ts , [b], drop a ts]
