#include <bits/stdc++.h>
using namespace std;
int a[35], n, k;
double dp[35][35][205];
double sum(int num) {
  double tmp = 0.0;
  for (int i = 1; i <= num; i++) tmp += i;
  return tmp;
}
int main() {
  memset(dp, 0, sizeof(dp));
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      if (a[i] > a[j]) dp[i][j][0] = 1;
  double p = sum(n);
  for (int t = 1; t <= k; t++) {
    for (int st = 0; st < n; st++) {
      for (int ed = st; ed < n; ed++) {
        for (int x = 0; x < n; x++) {
          for (int y = x; y < n; y++) {
            int tx = x, ty = y;
            if (st <= x && x <= ed) tx = ed - x + st;
            if (st <= y && y <= ed) ty = st + ed - y;
            if (ty >= tx)
              dp[x][y][t] += dp[tx][ty][t - 1] / p;
            else
              dp[x][y][t] += (1 - dp[ty][tx][t - 1]) / p;
          }
        }
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) ans += dp[i][j][k];
  printf("%.10f\n", ans);
}
