let [|n; k|] =
    stdin.ReadLine().Split(' ') |> Array.map int

let a =
    stdin.ReadLine().Split(' ') |> Array.map int64

let P = 1000000007L

let ans =
    let num1 =
        [|
            for i in 0 .. n - 1 do
                let num =
                    [|
                        for j in i + 1 .. n - 1 do
                            if a.[i] > a.[j] then
                                yield j
                    |]
                    |> Array.length
                yield num |> int64
        |]
        |> Array.reduce (fun acc num -> (acc + num) % P)
    let num2 =
        [|
            for i in 0 .. n - 1 do
                let num =
                    [|
                        for j in 0 .. n - 1 do
                            if a.[i] > a.[j] then
                                yield j
                    |]
                    |> Array.length
                yield num |> int64
        |]
        |> Array.reduce (fun acc num -> (acc + num) % P)
    let ans =
        let k = int64 k
        [0L .. k - 1L]
        |> List.map (fun i -> (num1 + num2 * i % P) % P)
        |> List.reduce (fun acc num -> (acc + num) % P)
    ans

ans |> stdout.WriteLine
