#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int invcnt = 0, cnt = 0, n;
void rec(vector<int> v, int k) {
  if (k == 0) {
    int i, j;
    for (i = 1; i <= n; ++i) {
      for (j = i + 1; j <= n; ++j) {
        if (v[j] < v[i]) {
          ++invcnt;
        }
      }
    }
    ++cnt;
    return;
  }
  int i, j, f;
  for (i = 1; i <= n; ++i) {
    for (j = i; j <= n; ++j) {
      vector<int> nv = v;
      int x = j;
      for (f = i; f <= j; ++f) {
        nv[f] = v[x];
        --x;
      }
      rec(nv, k - 1);
    }
  }
}
vector<int> a(11);
int main() {
  int i, j, k;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  rec(a, k);
  double ans = (double)invcnt / (double)cnt;
  printf("%.10lf", ans);
  return 0;
}
