#include <bits/stdc++.h>
using namespace std;
double pd[40][40][300];
int n, K;
int r[40];
int go(int a, int i, int j) {
  if (a < i || a > j) return a;
  return j - (a - i);
}
double solve(int a, int b, int k) {
  if (k == 0) return b < a;
  double& ret = pd[a][b][k];
  if (ret > -0.5) return ret;
  ret = 0;
  double mul = 1. / ((double)((n * (n + 1)) / 2));
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      int aa = go(a, i, j);
      int bb = go(b, i, j);
      ret += mul * solve(aa, bb, k - 1);
    }
  return ret;
}
int main() {
  cin >> n >> K;
  memset(pd, -1, sizeof pd);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    r[x] = i;
  }
  double ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      ans += solve(r[i], r[j], K);
    }
  printf("%.15f\n", ans);
  return 0;
}
