import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "before", long, "after");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto a = aryread();
    auto cnt = new Pair[](n);
    foreach (i; iota(n))
    {
        foreach (j; iota(n))
        {
            if (a[i] > a[j])
            {
                if (i > j)
                    cnt[i].before++;
                else
                    cnt[i].after++;
            }
        }
    }
    long init, addition;
    foreach (e; cnt)
    {
        init += e.after;
        addition += e.before + e.after;
    }
    auto ans = k * init % MOD;
    ans += ((k * (k - 1)) / 2) % MOD * addition;
    writeln(ans % MOD);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
