#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[40];
double dp[40][40][205];
int main() {
  scanf("%d%d", &n, &k);
  double pi = 2.0 / n / (n + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (p[i] > p[j]) dp[i][j][0] = 1;
  for (int u = 0; u < k; u++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (i != j) {
          for (int a = 1; a <= n; a++)
            for (int b = a; b <= n; b++) {
              if (a > min(i, j) && b < max(i, j))
                dp[i][j][u + 1] += pi * dp[i][j][u];
              if (b < min(i, j) || a > max(i, j))
                dp[i][j][u + 1] += pi * dp[i][j][u];
              if (i < j) {
                if (a <= i && b < j && b >= i)
                  dp[a + b - i][j][u + 1] += pi * dp[i][j][u];
                if (b >= j && a > i && a <= j)
                  dp[i][a + b - j][u + 1] += pi * dp[i][j][u];
                if (a <= i && b >= j)
                  dp[a + b - i][a + b - j][u + 1] += pi * dp[i][j][u];
              }
              if (i > j) {
                if (a <= j && b < i && b >= j)
                  dp[i][a + b - j][u + 1] += pi * dp[i][j][u];
                if (b >= i && a > j && a <= i)
                  dp[a + b - i][j][u + 1] += pi * dp[i][j][u];
                if (a <= j && b >= i)
                  dp[a + b - i][a + b - j][u + 1] += pi * dp[i][j][u];
              }
            }
        }
  double ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans += dp[i][j][k];
  printf("%.12f\n", ans);
}
