#include <bits/stdc++.h>
using namespace std;
const int N = 10000;
int n, k, a[N];
double ans = 0.0;
void dfs(int cnt, double p) {
  if (cnt == k) {
    int ret = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (a[i] > a[j]) ret++;
    ans += ret * p;
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      for (int l = i, r = j; l < r; l++, r--) swap(a[l], a[r]);
      dfs(cnt + 1, p / (n * (n + 1) / 2.0));
      for (int l = i, r = j; l < r; l++, r--) swap(a[l], a[r]);
    }
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  dfs(0, 1.0);
  printf("%.10f\n", ans);
  return 0;
}
