import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable long MOD = 1000000007;


auto solve(long N, long K, long[] A) {
    long ans;
    long a_inverse;
    foreach (i; 0 .. cast(size_t) N) foreach (j; i + 1 .. cast(size_t) N) {
        if (A[i] > A[j]) {
            a_inverse++;
            a_inverse %= MOD;
        }
    }
    ans += (K * a_inverse) % MOD;
    ans %= MOD;

    long nth;
    foreach (i, k; A.sort!"a > b"().group) {
        nth += k;
        ans += (((N - nth) * k) % MOD) * ((K * (K - 1) / 2) % MOD) % MOD;
        ans %= MOD;
    }

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N-1-0+1));
    foreach (i; 0 .. cast(size_t) (N-1-0+1)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, K, A);
    else
        solve(N, K, A).writeln;
}
