#include <bits/stdc++.h>
using namespace std;
const int TAM = 10100;
const int T_N = 31, T_K = 202;
double dp[T_N][T_N][T_K][2];
bool seen[T_N][T_N][T_K][2];
int nSegs, n;
int mirror(int i, int L, int R) {
  if (i < L || i > R) return i;
  return L + R - i;
}
double f(int i, int j, int k, bool inv) {
  double& r = dp[i][j][k][inv];
  if (seen[i][j][k][inv]++) return r;
  r = 0;
  if (k == 0) return r = (inv ? 1 : 0);
  int ni, nj;
  for (int L = 0; L < n; ++L)
    for (int R = L; R < n; ++R) {
      ni = mirror(i, L, R);
      nj = mirror(j, L, R);
      r += f(ni, nj, k - 1, inv ^ ((i < j) != (ni < nj)));
    }
  r /= double(nSegs);
  return r;
}
int main() {
  int k;
  cin >> n >> k;
  nSegs = n * (n - 1) / 2 + n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  double ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) ans += f(i, j, k, a[i] > a[j]);
  printf("%.12lf\n", double(ans));
  return 0;
}
