We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.  Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.  Find the inversion number of B, modulo 10^9 + 7.  Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.
n,k=map(int, input().split())
a=list(map(int, input().split()))
ans=0
x=0
y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j] and i>j:
            x+=1
        if a[i]>a[j] and i<j:
            y+=1
    print(x,y)
ans+=(x*(k-1)*k//2+y*k*(k+1)//2)%(10**9+7)
print(ans)
n,k=map(int, input().split())
a=list(map(int, input().split()))
ans=0
x=0
y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j] and i>j:
            x+=1
        if a[i]>a[j] and i<j:
            y+=1
ans+=(x*(k-1)*k//2+y*k*(k+1)//2)%(10**9+7)
print(ans)