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

main=do
 getLine
 t<-map read.words<$>getLine
 let ts = sum t
 getLine
 spl<-map (map read.words).lines<$>getContents
 mapM_ print$map (ac t ts) spl  