#include <bits/stdc++.h>
using namespace std;
int n;
int k;
string in;
map<string, long long> m[5];
long long cc;
void solve(int i) {
  if (i == k) return;
  for (typeof(m[i].begin()) it = (m[i].begin()); it != m[i].end(); it++) {
    string val = it->first;
    cc = 0;
    for (int x = 0; x < n; x++) {
      for (int y = x; y < n; y++) {
        string temp = "";
        for (int j = 0; j < x; j++) {
          temp.push_back(val[j]);
        }
        for (int j = y; j >= x; j--) {
          temp.push_back(val[j]);
        }
        for (int j = y + 1; j < n; j++) {
          temp.push_back(val[j]);
        }
        m[i + 1][temp] += it->second;
        cc++;
      }
    }
  }
  solve(i + 1);
}
long long inv(string in) {
  long long q = 0;
  for (int i = 0; i < n; i++) {
    char cur = in[i];
    for (int j = i + 1; j < n; j++) {
      if (cur > in[j]) q++;
    }
  }
  return q;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  in = "";
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    in.push_back('0' + x);
  }
  m[0][in] = 1;
  cc = -1;
  solve(0);
  double den = 1;
  for (int i = 0; i < k; i++) {
    den = den * cc;
  }
  den = 1 / den;
  double ans = 0;
  for (typeof(m[k].begin()) it = (m[k].begin()); it != m[k].end(); it++) {
    ans += ((it->second) * den) * inv(it->first);
  }
  printf("%0.10lf\n", ans);
}
