using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace jsc2019_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var numR = new long[N];
            var numL = new long[N];
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    if (A[i] > A[j])
                    {
                        numR[i] = numR[i] + 1;
                    }
                }
                for (int j = i - 1; j >= 0; j--)
                {
                    if (A[i] > A[j])
                    {
                        numL[i] = numL[i] + 1;
                    }
                }
            }

            mlong sumR = 0;
            foreach (var n in numR)
            {
                sumR = sumR + n;
            }

            mlong sumL = 0;
            foreach (var n in numL)
            {
                sumL = sumL + n;
            }

            Console.WriteLine(sumR * K * (K + 1) / 2 + sumL * K * (K - 1) / 2);
        }

        struct mlong
        {

            const long mod = (long)1e9 + 7;
            long V;

            public mlong(long _v = 0)
            {
                V = _v;
            }

            public static mlong operator +(mlong a, mlong b)
            {
                var v0 = a.V + b.V; if (v0 >= mod) v0 -= mod;
                return new mlong(v0);
            }
            public static mlong operator -(mlong a, mlong b)
            {
                var v0 = mod + a.V - b.V; if (v0 >= mod) v0 -= mod;
                return new mlong(v0);
            }
            public static mlong operator -(mlong b)
            {
                var v0 = mod - b.V; if (v0 >= mod) v0 -= mod;
                return new mlong(v0);
            }
            public static mlong operator *(mlong a, mlong b)
            {
                var v0 = a.V * b.V; if (v0 >= mod) v0 %= mod;
                return new mlong(v0);
            }
            public static mlong operator /(mlong a, mlong b)
            {
                var v0 = a.V * inv(b.V).V; if (v0 >= mod) v0 %= mod;
                return new mlong(v0);
            }


            public static mlong inv(long x)
            {
                long a = 0, b = 0, c = 0;
                ExtGCD(x, mod, ref a, ref b, ref c);
                return (mlong)((a + mod) % mod);
            }

            public static void ExtGCD(long x, long y, ref long a, ref long b, ref long c)
            {
                long r0 = x; long r1 = y;
                long a0 = 1; long a1 = 0;
                long b0 = 0; long b1 = 1;
                long q1, r2, a2, b2;
                while (r1 > 0)
                {
                    q1 = r0 / r1;
                    r2 = r0 % r1;
                    a2 = a0 - q1 * a1;
                    b2 = b0 - q1 * b1;
                    r0 = r1; r1 = r2;
                    a0 = a1; a1 = a2;
                    b0 = b1; b1 = b2;
                }
                c = r0;
                a = a0;
                b = b0;
            }

            public static mlong ModPow(mlong a, long k)
            {
                if (k == 0) return (mlong)1;
                if (a == 0) return (mlong)0;
                mlong x = a;
                mlong ret = 1;
                while (k > 0)
                {
                    if (k % 2 == 1) ret *= x;
                    x *= x;
                    k >>= 1;
                }
                return ret;
            }


            public static bool operator ==(mlong a, mlong b)
            {
                return a.Equals(b);
            }
            public static bool operator !=(mlong a, mlong b)
            {
                return !(a == b);
            }

            public override bool Equals(System.Object obj)
            {
                if (obj == null) return false;
                mlong p = (mlong)obj;
                if ((System.Object)p == null) return false;
                return p.V == V;
            }
            public override int GetHashCode()
            {
                return V.GetHashCode();
            }

            public static implicit operator mlong(long n)
            {
                long v = n % mod; if (v < 0) v += mod;
                return new mlong(v);
            }
            public static implicit operator mlong(int n)
            {
                long v = n % mod; if (v < 0) v += mod;
                return new mlong(v);
            }
            public static explicit operator long(mlong n)
            {
                return n.V;
            }

            public override String ToString()
            {
                return V.ToString();
            }


        }
    }
}


Measured memory_bytes: 13268