#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
double ans, dp[205][35][35];
int vis[205][35][35];
int n, k, v[35], tot;
double Dfs(int l, int r, int m) {
  if (vis[m][l][r]) return dp[m][l][r];
  if (m == 0) {
    if (l <= r) return 1.0;
    return 0.0;
  }
  double res = 0.0;
  for (int X = 1; X <= (n); ++X)
    for (int Y = (X); Y <= (n); ++Y) {
      int tl = l, tr = r;
      if (X <= tl && tl <= Y) tl = X + Y - tl;
      if (X <= tr && tr <= Y) tr = X + Y - tr;
      res += Dfs(tl, tr, m - 1) / (double)tot;
    }
  vis[m][l][r] = 1;
  return dp[m][l][r] = res;
}
int main() {
  memset(vis, 0, sizeof(vis));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= (n); ++i) scanf("%d", v + i);
  tot = n * (n + 1) / 2;
  for (int i = 1; i <= (n); ++i)
    for (int j = (i + 1); j <= (n); ++j) {
      double res = Dfs(i, j, k);
      if (v[i] < v[j])
        ans += (1.0 - res);
      else
        ans += res;
    }
  printf("%.15f\n", ans);
  return 0;
}
