program main
	integer(8) n,k,i,j
    integer(8),allocatable::a(:)
    integer(8)::ans=0,s=0
    integer(8),parameter::m=1000000007_8
    read *,n,k
    allocate(a(n))
    read *, (a(i),i=1,n)
    do i=1,n
    	do j=1,i-1
        	if(a(i)<a(j)) ans=ans+1
        end do
    end do
    ans=mod(ans*k,m)
    do i=1,n
    	do j=1,n
        	if(a(i)<a(j))s=s+1
        end do
    end do
    ans=mod(ans+s*mod(k*(k-1)/2,m),m)
    print '(i0)',ans
end program main