program main
	implicit none
	integer :: N, M
	integer, allocatable :: T(:), P(:), X(:)
	integer :: S, i
	
	read(*, *) N
	allocate(T(1:N))
	read(*, *) T
	read(*, *) M
	allocate(P(1:M), X(1:M))
	do i = 1, M
		read(*, *) P(i), X(i)
	end do
	
	S = sum(T)
	do i = 1, M
		write(*, *) S + X(i) - T(P(i))
	end do
	
end program main