program pr2
  implicit none
  integer :: i, j, n, m
  integer,allocatable,dimension(:) :: p, x, t, t1
  
  read(*,*) n
  allocate(t(n),t1(n))
  read(*,*) t
  read(*,*) m
  allocate(p(m),x(m))
  do i = 1, m
     read(*,*) p(i), x(i)
  end do
  t1 = t
  do i = 1, m
     t1(p(i)) = x(i)
     write(*,*) sum(t1)
     t1(p(i)) = t(p(i))
  end do
  stop
  
end program pr2
