#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e6 + 10;
double dp[201][30][30];
int a[33];
int main() {
  int n, K;
  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 + 1); j < (n); ++j) {
      if (a[i] < a[j])
        dp[0][i][j] = 1;
      else
        dp[0][j][i] = 1;
    }
  int qq = n * (n + 1) / 2;
  for (int i = 0; i < (K); ++i) {
    for (int j = 0; j < (n); ++j)
      for (int k = 0; k < (n); ++k) {
        if (j == k) continue;
        for (int j2 = 0; j2 < (n); ++j2)
          for (int k2 = (j2); k2 < (n); ++k2) {
            int jj = j, kk = k;
            if (j2 <= jj && k2 >= jj) jj = k2 - (jj - j2);
            if (j2 <= kk && k2 >= kk) kk = k2 - (kk - j2);
            dp[i + 1][jj][kk] += dp[i][j][k] / qq;
          }
      }
  }
  double an = 0;
  for (int i = 0; i < (n); ++i)
    for (int j = (i + 1); j < (n); ++j) an += dp[K][j][i];
  printf("%.12f\n", an);
  return 0;
}
