program main
	implicit none
    integer::n,m,i
    integer(8),allocatable::t(:),p(:),x(:),ans(:)
    integer(8)::a,b,sum1
    read(*,*) n
    allocate(t(n))
    read(*,*) t
    read(*,*) m
    allocate(p(m), x(m), ans(m))
    do i=1,m
    	read(*,*) a,b
        p(i)=a
        x(i)=b
    end do
    ans=sum(t)
    
    do i=1,m
    	ans(i)=ans(i)-(t(p(i))-x(i))
    end do
    
    do i=1,m
    	write(*,*) ans
    end do
    deallocate(t,p,x,ans)
    stop
end program main
    
        