#include <bits/stdc++.h>
using namespace std;
int n, m;
int state[10000];
int cnt, sum;
void dfs(int depth) {
  if (depth >= m) {
    for (int i = 0; i < n - 1; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (state[i] > state[j]) ++cnt;
      }
    }
  } else {
    for (int i = 0; i < n; ++i) {
      for (int j = i; j < n; ++j) {
        for (int a = i, b = j; a < b; ++a, --b) swap(state[a], state[b]);
        dfs(depth + 1);
        for (int a = i, b = j; a < b; ++a, --b) swap(state[a], state[b]);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &state[i]);
  }
  cnt = 0;
  dfs(0);
  double ans = cnt / pow(n * (n - 1) / 2 + n, m);
  printf("%.12f\n", ans);
  return 0;
}
