implicit none integer(8) A,B,f,i,k,m,n integer(8),allocatable :: x(:) read(*,*) k,n,f allocate (x(f)) read(*,*) (x(m),m=1,f) A=0 do m=1,f A=A+x(m) end do B=k*n-A if (B>=0) then write(*,*) B else write(*,*) "-1" end if end