let () =
  let xs = Scanf.scanf "%d" (fun n -> Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))) in
  let total = Array.fold_left (+) 0 xs in
  Scanf.scanf " %d" (fun m -> Array.init m (fun _ -> Scanf.scanf " %d %d" (fun p u -> (p, u))))
  |> Array.iter (fun (p, u) -> Printf.printf "%d\n" (total + (u-xs.(p-1))))
