#include <bits/stdc++.h>
using namespace std;
const long long LINF = (long long)1e9;
const int maxN = 33;
const int maxK = 222;
int a[maxN];
double dp[maxK][maxN][maxN];
int f(int i, int l, int r) { return (l <= i && i <= r) ? l + r - i : i; }
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[0][i][j] = (a[i] > a[j]);
    }
  }
  for (int ii = 0; ii < k; ii++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int l = 0; l < n; l++) {
          for (int r = l; r < n; r++) {
            dp[ii + 1][f(i, l, r)][f(j, l, r)] +=
                dp[ii][i][j] / (double)((n * (n + 1)) / 2.0);
          }
        }
      }
    }
  }
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      ans += dp[k][i][j];
    }
  }
  printf("%.16f", ans);
  return 0;
}
