#include <bits/stdc++.h>
using namespace std;
int n, m, A[10];
double sol, p, mk[100];
double eps = 1e-9;
void rec(int k, int *A) {
  int val = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++)
      if (A[j] > A[i]) val++;
  if (k == m) {
    sol += (val + 0.0) / p;
    return;
  }
  int T[10];
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      for (int h = 1; h <= n; h++) T[h] = A[h];
      for (int h = i, t = j; h <= j; h++, t--) T[h] = A[t];
      rec(k + 1, T);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  p = 1;
  double b = n * (n + 1) / 2;
  for (int i = 1; i <= m; i++) p *= b;
  rec(0, A);
  printf("%.13lf\n", sol);
  return 0;
}
