#include <bits/stdc++.h>
using namespace std;
int a[10], n, k, sum, cnt;
void dfs(int d) {
  if (d == k) {
    ++cnt;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j) {
        if (a[i] > a[j]) ++sum;
      }
  } else {
    for (int i = 0; i < n; ++i)
      for (int j = i; j < n; ++j) {
        reverse(a + i, a + j + 1);
        dfs(d + 1);
        reverse(a + i, a + j + 1);
      }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  dfs(0);
  printf("%.9f\n", double(sum) / cnt);
  return 0;
}
