import Control.Monad

ac t ts [] = []
ac t ts sp = ts + (last sp) - (t!!(head sp - 1))) 

main=do
 getLine
 t<-map read.words<$>getLine
 let ta = sum t
 m<-readLn
 spl<-map (map read.words).lines<$>getContents
 putStrLn.unlines$init$map show$map (ac t ts) spl  