import Control.Monad
import Data.Array
main = readLn >>= main'
    where
        main' n = getLine >>= main'' n . map read . words
        main'' n ts = getLine >> getContents >>= mapM_ print . solve (sum ts) (listArray (1, n) ts) . map (map read . words) . lines

solve :: Int -> Array Int Int -> [[Int]] -> [Int]
solve s ts = map (\[p, x] -> s - ts ! p + x)
