#include <bits/stdc++.h>
using namespace std;
const int N = 30;
double f[N][N];
double g[N][N];
int a[N];
int n;
int k;
int get(int l, int r, int x) {
  if (x < l || x > r) return x;
  return r - (x - l);
}
int main() {
  ios::sync_with_stdio(false);
  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)
      if (i != j) {
        f[i][j] = i < j ? 1.0 : 0.0;
      }
  }
  int div = n * (n + 1) / 2;
  for (int run = 0; run < k; ++run) {
    memset(g, 0, sizeof g);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j)
        if (i != j) {
          for (int l = 0; l < n; ++l) {
            for (int r = l; r < n; ++r) {
              g[i][j] += f[get(l, r, i)][get(l, r, j)];
            }
          }
          g[i][j] /= div;
        }
    }
    memcpy(f, g, sizeof f);
  }
  double result = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[i] > a[j])
        result += f[i][j];
      else
        result += 1 - f[i][j];
    }
  }
  printf("%.12lf\n", result);
  return 0;
}
