import Control.Monad
f :: [Int]->[[Int]]->[Int]
f l a= if null a then [] else[sum l+(last.head) a-(l!!((head.head)a-1))]++f l (tail a)
main=do
 n<-getLine
 l<-map read.words<$>getLine
 m<-readLn
 a<-map (map read).map words<$>replicateM m getLine
 putStrLn.init.unlines.map show.f l$a