#include <bits/stdc++.h>
using namespace std;
int n;
double memo[30][30][201];
double solve(int pos1, int pos2, int k) {
  if (k == 0) {
    if (pos1 < pos2) return 0;
    return 1;
  }
  double &ret = memo[pos1][pos2][k];
  if (!(ret == ret)) {
    ret = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i; j < n; ++j) {
        int x = pos1;
        if (i <= pos1 && pos1 <= j) x = i + j - pos1;
        int y = pos2;
        if (i <= pos2 && pos2 <= j) y = i + j - pos2;
        ret += solve(x, y, k - 1);
      }
    }
    ret /= (n * (n + 1) / 2);
  }
  return ret;
}
int main() {
  int k;
  scanf("%d %d", &n, &k);
  int p[n];
  for (int i = 0; i < n; ++i) scanf("%d", &p[i]);
  memset(memo, -1, sizeof memo);
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (p[i] < p[j]) {
        ans += solve(i, j, k);
      } else {
        ans += 1 - solve(i, j, k);
      }
    }
  }
  printf("%.12f\n", ans);
  return 0;
}
