#include <bits/stdc++.h>
using namespace std;
double DP[105][105], ans, dp[105][105];
int a[105], n, m, i, j, k, l, X, Y;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (a[i] > a[j]) dp[i][j] = 1;
  while (m--) {
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) {
        DP[i][j] = dp[i][j];
        dp[i][j] = 0;
      }
    for (i = 1; i <= n; i++)
      for (j = i; j <= n; j++)
        for (k = 1; k <= n; k++)
          for (l = 1; l <= n; l++) {
            if (k > j || k < i)
              X = k;
            else
              X = j - (k - i);
            if (l > j || l < i)
              Y = l;
            else
              Y = j - (l - i);
            dp[k][l] += DP[X][Y] / (n * (n + 1) / 2.0);
          }
  }
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) ans += dp[i][j];
  printf("%.10f\n", ans);
  return 0;
}
