program main
implicit none
integer :: i, j, k
integer :: n, m
integer , allocatable :: x(:), t(:), p(:)

read(*,*) n
allocate( x(n) )
read(*,*) x
read(*,*) m
allocate( t(m), p(m) )
j = sum( x )
do i = 1, m
   read(*,*) t(i), p(i)
   k = t(i)
   write(*,'(i0)') j - x(k) + p(i)
end do


end program main
