import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

void naive(long k, int[] a) {
    int[] b;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < a.length; j++) {
            b ~= a[j];
        }
    }

    long ans = 0;
    for (int i = 0; i < b.length; i++) {
        for (int j = i + 1; j < b.length; j++) {
            if (b[i] > b[j]) {
                ans++;
                ans %= MOD;
            }
        }
    }
    writeln("ans ", ans);
}

long calc(long k, int[] a) {
    long ans = 0;
    for (int i = 0; i < a.length; i++) {
        long left = 0;
        long right = 0;
        for (int j = i + 1; j < a.length; j++) {
            if (a[i] > a[j]) right++;
        }
        for (int j = i - 1; j >= 0; j--) {
            if (a[i] > a[j]) left++;
        }

        long t = (k * (k + 1) / 2) % MOD;
        long x = right * t % MOD;
        x += left * (((k - 1) * k) / 2 % MOD) % MOD;
        ans = (ans + x) % MOD;
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    auto a = readints;
    writeln(calc(k, a));
}
