#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const int MAXN = 31;
const int MAXK = 201;
long double f1[MAXN][MAXN];
long double f2[MAXN][MAXN];
long double coff;
long double a[MAXN];
int n, k;
inline int go(int id, int l, int r) {
  if ((id > r) || (id < l))
    return id;
  else
    return (l + r - id);
}
int main() {
  cin >> n >> k;
  coff = 2.0 / (long double)n / (long double)(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      f1[i][j] = 0;
      f1[j][i] = 1;
    }
    f1[i][i] = 0;
  }
  for (int iter = 0; iter < k; iter++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        f2[i][j] = f1[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        f1[i][j] = 0;
        for (int l = 0; l < n; l++) {
          for (int r = l; r < n; r++) {
            f1[i][j] += f2[go(i, l, r)][go(j, l, r)] * coff;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] < a[j])
        ans += f1[j][i];
      else
        ans += f1[i][j];
    }
  }
  ios_base::sync_with_stdio(0);
  cout.precision(40);
  cout << ans << endl;
  return 0;
}
