#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#include<bits/stdc++.h>
 
#define tc int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define ll long long
#define pb push_back
#define ins insert
#define er erase
 
#define f(i,a,b) for(i=a;i<b;++i)
#define rf(i,a,b) for(i=a;i>=b;--i)
 
#define vi vector<int> 
#define vll vector<ll> 
#define vc vector<char>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
 
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
 
#define bs bitset
 
#define mii map<int,int>
#define mll map<ll,ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
 
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
 
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a)*1ll*(b))/gcd(a,b) 
 
#define nl "\n" 
#define sp " "
 
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ok order_of_key
 
 
ll md = 1000*1000*1000+7;
 
/* 
ll pw(ll a, ll b){
    ll c=1, m=a;
    while(b){
        if(b&1)c=(c*m)%md;
        m=(m*m)%md;b/=2;
    }
    return c;
} 

ll modinv(ll n){
    return pw(n, md - 2) ;
}
 
ll mul(ll a, ll b, ll c, ll d){
    return (((((a*b)%md)*c)%md)*d)%md ;
}

*/
 
/*inline int nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
 
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
*/
 
 /* int find(int a){
    if(a == root[a]) return a ;
    else if(root[a] == root[root[a]]) return root[a] ;
    else return find(root[root[a]]) ;
}
 
void union1(int a, int b){
    a = find(a), b = find(b) ;
    if(a == b) return ;
    if(size1[a] > size1[b]){
        root[b] = a ;
        size1[a] += size1[b] ;
    }
    else{
        root[a] = b ;
        size1[b] += size1[a] ;
    }
}*/ 
 
 
/* bool mocmp(pair<pii,int>x, pair<pii,int> y){
    int blockx = x.ff.ff/blocksize, blocky = y.ff.ff/blocksize;
    if(blocky != blockx) return blockx < blocky;
    return x.ff.ss < y.ff.ss;
}*/
/* 
ll my_ceil(ll a, ll b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
*/

/*
void update(int idx, int val ){
    while(idx <= n){
        fenwick[idx] += val ;
        idx += (idx & (-idx)) ; 
    }
}
 
ll sum(int idx){
    ll ans = 0 ; 
    while(idx > 0){
        ans += fenwick[idx] ;
        idx -= (idx & (-idx)) ;
    }
    return ans ;
}
 */
 
/* int lps(string s){
    int i = 1, len = 0, n = s.size() ;
    int ans[n] ;
    ans[0] = 0 ;
    while(i < n){
        if(s[i] == s[len]) ans[i++] = ++len ;
        else{
            if(len) len = ans[len - 1] ;
            else ans[i++] = 0 ;
        }
    }
    return ans[n - 1] ;
}*/

inline ll add(ll a, ll b){ return (a + b) % md ; }
inline ll subt(ll a, ll b){ return (a - b + md) % md ;}
inline ll mult(ll a, ll b){ return (1ll * a * b) % md ;}
 
//LET'S PLAY THE GAME!!

int main(){
    fast;
    
    int i, j, k ;

    int n ; cin >> n >> k ;
    int a[n] ;
    f(i, 0, n) cin >> a[i] ;
    int temp1 = 0, temp2 = 0 ;
    f(i, 0, n){
        f(j, 0, i){
            if(a[j] < a[i]) temp2++ ;
        }
        f(j, i + 1, n){
            if(a[j] < a[i]) temp1++ ;
        }
    }

    cout << add(mult(((1ll * k * (k + 1))/2) % md, temp1), mult(((1ll * k * (k - 1))/2) % md, temp2)) ;
 
    return 0 ;
    
}
// AND THE GAME IS OVER !!

Measured memory_bytes: 256