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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


enum L = 2001;

void main() {
    int n, k;
    scan(n, k);

    auto a = readln.split.to!(int[]);

    int I;

    foreach (i ; 1 .. n) {
        foreach (j ; 0 .. i) {
            if (a[j] > a[i]) {
                I++;
            }
        }
    }

    long ans = 1L * I * k % mod;


    auto c = new int[](L);

    foreach (i ; 0 .. n) {
        c[a[i]]++;
    }

    auto cc = new int[](L + 1);

    foreach (i ; 1 .. L + 1) {
        cc[i] = cc[i - 1] + c[i - 1];
    }

    long p;

    foreach (i ; 0 .. L) {
        p += c[i] * cc[i] % mod;
        p %= mod;
    }

    ans += p * (1L * k * (k - 1) / 2 % mod) % mod;
    ans %= mod;

    writeln(ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}
