import Control.Monad
ac tn t ns p =if (head p)`elem`ns then tn+((last p)-(t!!(head p))) else tn
main=do
 n<-readLn
 t<-map read.words<$>getLine
 m<-readLn
 px<-replicateM m (map read.words<$>getLine)
 let ns=[1..n]
 putStrLn$unlines$map show$map (ac (sum t) t ns) px
