#include <bits/stdc++.h>
using namespace std;
const int N = 35;
double dp[205][N][N];
int n, k, a[N];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (a[i] > a[j])
        dp[0][i][j] = 1.0;
      else
        dp[0][i][j] = 0.0;
  }
  double tot = n * (n + 1) / 2.0;
  for (int p = 0; p < k; p++) {
    for (int l = 0; l < n; l++) {
      for (int r = l; r < n; r++) {
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < n; j++) {
            int ii = i, jj = j;
            if (i >= l && i <= r) ii = r - i + l;
            if (j >= l && j <= r) jj = r - j + l;
            dp[p + 1][i][j] += dp[p][ii][jj] / tot;
          }
        }
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      ans += dp[k][i][j];
    }
  printf("%.10f\n", ans);
  return 0;
}
