import Control.Monad
import qualified Data.IntMap as IM

solve :: [(Int, Int)] -> [Int] -> [Int]
solve [] _ = []
solve (px:pxs) ts = (sum $ solve' px ts 1) : solve pxs ts

solve' :: (Int, Int) -> [Int] -> Int -> [Int]
solve' _ [] _ = []
solve' px@(p, x) (t:ts) count = current : solve' px ts (count + 1)
  where current = if p == count
                  then x
                  else t

main :: IO ()
main = do
  getLine
  ts <- map read . words <$> getLine :: IO [Int]
  let tis = IM.fromList $ zip [1..] ts
  m <- readLn
  let toTuple [x, y] = (x, y)
  pxs <- replicateM m $ toTuple . map read . words <$> getLine :: IO [(Int, Int)]
  mapM_ print $ solve pxs ts