import Control.Monad

ac :: [Int]->Int->[Int]->Int
ac t ts sp = ts + ((last sp) - (t!!(head sp))) 

main=do
 getLine
 t<-map read.words<$>getLine
 m<-readLn
 spl<-replicateM m (map read.words<$>getLine) 
 putStrLn.unlines$map (ac t (sum t)) spl  