#include <bits/stdc++.h>
using namespace std;
const int MAXN = 32 + 10;
const int INF = 1000000000;
const int MOD = (int)(1e9) + 7;
int a[MAXN];
int n, m;
double prob[MAXN][MAXN][MAXN][MAXN], f[MAXN][MAXN], ff[MAXN][MAXN];
double res, p;
void pre(int u, int v) {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) prob[u][v][i][j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int uu = ((u < i) || (u > j)) ? u : (i + j - u);
      int vv = ((v < i) || (v > j)) ? v : (i + j - v);
      prob[u][v][uu][vv] += p;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  p = (double)(1) / ((n * (n + 1)) / 2);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) pre(i, j);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i] > a[j])
        f[i][j] = 1.0;
      else
        f[i][j] = 0.0;
      ff[i][j] = 0.0;
    }
  }
  for (int k = 1; k <= m; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) ff[i][j] = 0.0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int u = 1; u <= n; u++) {
          for (int v = 1; v <= n; v++) {
            ff[u][v] += f[i][j] * prob[i][j][u][v];
          }
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) f[i][j] = ff[i][j];
    }
  }
  res = 0.0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) res += f[i][j];
  }
  printf("%.11lf\n", res);
}
