import Control.Monad
ac tn t p = tn-(last(t!!(head p))-last p) 
main=do
 n<-readLn
 t<-map read.words<$>getLine
 m<-readLn
 px<-replicateM m (map read.words<$>getLine)
 print$unwords$map (ac (sum t) t) px