program answer
  implicit none

  integer :: N, M, i
  integer, allocatable :: T(:), P(:), X(:)

  read(*,*) N
  allocate(T(N))
  read(*,*) T
  read(*,*) M
  allocate(P(M))
  allocate(X(M))
  do i = 1, M
     read(*,*) P(i), X(i)
  end do

  do i = 1, M
     write(*,*) sum(T)-T(P(i))+X(i)
  end do

  stop
 end program answer
  