Scanf.scanf "%d" (fun n ->
    let t = Array.init n (fun _ -> Scanf.scanf " %d" (fun t -> t)) in
    let sum = Array.fold_left (+) 0 t in
    Scanf.scanf " %d" (fun m ->
        for i = 1 to m do
            Scanf.scanf " %d %d" (fun p x ->
                let p = p - 1 in
                Printf.printf "%d\n" @@ sum + x - t.(p)
            )
        done
    )
)