#include <bits/stdc++.h>
const int MAXN = 31;
const int N = 201;
double f[N][MAXN][MAXN];
int a[MAXN];
double solve(int n, int m) {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) f[0][i][j] = a[i] > a[j];
  double p = 2.0 / n / (n + 1);
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        for (int x = 0; x < n; ++x) {
          for (int y = x; y < n; ++y) {
            int l = j, r = k;
            if (x <= l && l <= y) l = x + y - l;
            if (x <= r && r <= y) r = x + y - r;
            f[i + 1][l][r] += p * f[i][j][k];
          }
        }
      }
    }
  }
  double res = 0.0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) res += f[m][i][j];
  return res;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  printf("%.15f\n", solve(n, m));
  return 0;
}
