main :: IO ()
main = do
  n <- readLn :: IO Int
  ts <- map read . words <$> getLine
  m <- readLn :: IO Int
  pxs <- mapM readPX [1..m] :: IO [(Int, Int)]
  mapM (putStrLn . solve ts) pxs
  return ()
  where
    readPX _ = do
      [p, x] <- map read . words <$> getLine
      return (p,x)
    solve ts (p, x) =
      show . snd  $ foldl (add' (p, x)) (1, 0) ts
      where
        add' (p, x) (i, l) r =
          if p == i
          then (i+1, l + x)
          else (i+1, l + r)
