#include <bits/stdc++.h>
using namespace std;
const int N = 30 + 5, K = 200 + 3;
double dp[N][N][K][2];
bool done[N][N][K][2];
int n, a[N];
double p;
inline double calc(int a, int b, int k, int cmp) {
  if (done[a][b][k][cmp]) return dp[a][b][k][cmp];
  done[a][b][k][cmp] = 1;
  if (k == 0) return dp[a][b][k][cmp] = cmp + 0.0;
  int na, nb, ncmp;
  double x = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      na = a < i ? a : (a > j ? a : i + j - a);
      nb = b < i ? b : (b > j ? b : i + j - b);
      ncmp = (na < nb ? cmp : cmp ^ 1);
      if (na > nb) swap(na, nb);
      x += p * calc(na, nb, k - 1, ncmp);
    }
  return dp[a][b][k][cmp] = x;
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  p = (double)2.0 / (double)(n * (n + 1));
  double res = 0;
  memset(dp, 0, sizeof dp);
  memset(done, 0, sizeof done);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) res += calc(i, j, k, a[i] > a[j]);
  printf("%.11lf\n", res);
  return 0;
}
