#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef double LF;
int N, K, cnt, inv[10000];
string S[10000], init;
map <string,int> M;
LF prob, dp[1000][4];
int comp(string x) {
int ret = 0;
for (int i=0;i<N;++i)
for (int j=i+1;j<N;++j)
if (x[i] > x[j]) ret++;
return ret;
}
LF cal(int x,int k) {
if (dp[x][k] != 0.0) return dp[x][k];
if (k == 0) dp[x][k] = inv[x];
else {
for (int i=0;i<N;++i)
for (int j=i;j<N;++j) {
string s = S[x];
reverse(s.begin()+i,s.begin()+j+1);
dp[x][k] += prob * cal(M[s],k-1);
}
}
// printf("dp(%s, %d) = %.9lf\n",S[x].c_str(),k,dp[x][k]);
return dp[x][k];
}
int main () {
scanf("%d%d",&N,&K);
for (int i=0;i<N;++i) {
int t;
scanf("%d",&t);
init += ('0' + t);
}
prob = 2.0 / (LF)(N * (N+1));
string tmp = "";
for (int i=1;i<=N;++i) tmp += ('0' + i);
do {
M[tmp] = ++cnt;
S[cnt] = tmp;
} while (next_permutation(tmp.begin(),tmp.end()));
for (int i=1;i<=cnt;++i) inv[i] = comp(S[i]);
//for (int i=1;i<=cnt;++i) cout << S[i] << ": " << inv[i] << endl;
//cout << init << endl;
printf("%.12lf\n",cal(M[init],K));
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPG1hcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgZG91YmxlIExGOwppbnQgTiwgSywgY250LCBpbnZbMTAwMDBdOwpzdHJpbmcgU1sxMDAwMF0sIGluaXQ7Cm1hcCA8c3RyaW5nLGludD4gTTsKTEYgcHJvYiwgZHBbMTAwMF1bNF07CgppbnQgY29tcChzdHJpbmcgeCkgewogIGludCByZXQgPSAwOwogIGZvciAoaW50IGk9MDtpPE47KytpKQogICAgZm9yIChpbnQgaj1pKzE7ajxOOysraikKICAgICAgaWYgKHhbaV0gPiB4W2pdKSByZXQrKzsKICByZXR1cm4gcmV0Owp9CgpMRiBjYWwoaW50IHgsaW50IGspIHsKICBpZiAoZHBbeF1ba10gIT0gMC4wKSByZXR1cm4gZHBbeF1ba107CiAgaWYgKGsgPT0gMCkgZHBbeF1ba10gPSBpbnZbeF07CiAgZWxzZSB7CiAgICBmb3IgKGludCBpPTA7aTxOOysraSkKICAgICAgZm9yIChpbnQgaj1pO2o8TjsrK2opIHsKICAgICAgICBzdHJpbmcgcyA9IFNbeF07CiAgICAgICAgcmV2ZXJzZShzLmJlZ2luKCkraSxzLmJlZ2luKCkraisxKTsKICAgICAgICBkcFt4XVtrXSArPSBwcm9iICogY2FsKE1bc10say0xKTsKICAgICAgfQogIH0KLy8gIHByaW50ZigiZHAoJXMsICVkKSA9ICUuOWxmXG4iLFNbeF0uY19zdHIoKSxrLGRwW3hdW2tdKTsKICByZXR1cm4gZHBbeF1ba107Cn0KCmludCBtYWluICgpIHsKICBzY2FuZigiJWQlZCIsJk4sJkspOwogIGZvciAoaW50IGk9MDtpPE47KytpKSB7CiAgICBpbnQgdDsKICAgIHNjYW5mKCIlZCIsJnQpOwogICAgaW5pdCArPSAoJzAnICsgdCk7CiAgfQogIHByb2IgPSAyLjAgLyAoTEYpKE4gKiAoTisxKSk7CiAgc3RyaW5nIHRtcCA9ICIiOwogIGZvciAoaW50IGk9MTtpPD1OOysraSkgdG1wICs9ICgnMCcgKyBpKTsKICBkbyB7CiAgICBNW3RtcF0gPSArK2NudDsKICAgIFNbY250XSA9IHRtcDsKICB9IHdoaWxlIChuZXh0X3Blcm11dGF0aW9uKHRtcC5iZWdpbigpLHRtcC5lbmQoKSkpOwogIGZvciAoaW50IGk9MTtpPD1jbnQ7KytpKSBpbnZbaV0gPSBjb21wKFNbaV0pOwogIC8vZm9yIChpbnQgaT0xO2k8PWNudDsrK2kpIGNvdXQgPDwgU1tpXSA8PCAiOiAiIDw8IGludltpXSA8PCBlbmRsOwogIC8vY291dCA8PCBpbml0IDw8IGVuZGw7CiAgcHJpbnRmKCIlLjEybGZcbiIsY2FsKE1baW5pdF0sSykpOwp9