#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40;
const int MAXM = 210;
int n, m, A[MAXN];
double p[MAXM][MAXN][MAXN];
void lucky() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
}
int main() {
  lucky();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) p[0][i][j] = (A[i] > A[j]);
  double rat = 1.0 / (0.5 * n * (n + 1));
  for (int R = 1; R <= m; R++)
    for (int l = 1; l <= n; l++)
      for (int r = l; r <= n; r++) {
        for (int i = 1; i <= n; i++)
          for (int j = 1; j <= n; j++) {
            int x = (l <= i && i <= r) ? l + r - i : i;
            int y = (l <= j && j <= r) ? l + r - j : j;
            p[R][i][j] += rat * p[R - 1][x][y];
          }
      }
  double ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans += p[m][i][j];
  printf("%.10lf\n", ans);
  return 0;
}
