#include <bits/stdc++.h>
using namespace std;
void reader(int *x) {
  int k, m = 0;
  *x = 0;
  for (;;) {
    (k) = getchar();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      *x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar();
    if (k < '0' || k > '9') break;
    *x = (*x) * 10 + k - '0';
  }
  if (m) (*x) = -(*x);
}
void reader(long long *x) {
  int k, m = 0;
  *x = 0;
  for (;;) {
    (k) = getchar();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      *x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar();
    if (k < '0' || k > '9') break;
    *x = (*x) * 10 + k - '0';
  }
  if (m) (*x) = -(*x);
}
void reader(double *x) { scanf("%lf", x); }
int reader(char c[]) {
  int i, s = 0;
  for (;;) {
    (i) = getchar();
    if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break;
  }
  c[s++] = i;
  for (;;) {
    (i) = getchar();
    if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break;
    c[s++] = i;
  }
  c[s] = '\0';
  return s;
}
template <class T, class S>
void reader(T *x, S *y) {
  reader(x);
  reader(y);
}
template <class T, class S, class U>
void reader(T *x, S *y, U *z) {
  reader(x);
  reader(y);
  reader(z);
}
template <class T, class S, class U, class V>
void reader(T *x, S *y, U *z, V *w) {
  reader(x);
  reader(y);
  reader(z);
  reader(w);
}
void writer(int x, char c) {
  int s = 0, m = 0;
  char f[10];
  if (x < 0) m = 1, x = -x;
  while (x) f[s++] = x % 10, x /= 10;
  if (!s) f[s++] = 0;
  if (m) putchar('-');
  while (s--) putchar(f[s] + '0');
  putchar(c);
}
void writer(long long x, char c) {
  int s = 0, m = 0;
  char f[20];
  if (x < 0) m = 1, x = -x;
  while (x) f[s++] = x % 10, x /= 10;
  if (!s) f[s++] = 0;
  if (m) putchar('-');
  while (s--) putchar(f[s] + '0');
  putchar(c);
}
void writer(double x, char c) {
  printf("%.15f", x);
  putchar(c);
}
void writer(const char c[]) {
  int i;
  for (i = 0; c[i] != '\0'; i++) putchar(c[i]);
}
void writer(const char x[], char c) {
  int i;
  for (i = 0; x[i] != '\0'; i++) putchar(x[i]);
  putchar(c);
}
template <class T>
void writerLn(T x) {
  writer(x, '\n');
}
template <class T, class S>
void writerLn(T x, S y) {
  writer(x, ' ');
  writer(y, '\n');
}
template <class T, class S, class U>
void writerLn(T x, S y, U z) {
  writer(x, ' ');
  writer(y, ' ');
  writer(z, '\n');
}
template <class T>
void writerArr(T x[], int n) {
  int i;
  if (!n) {
    putchar('\n');
    return;
  }
  for (i = 0; i < n - 1; i++) writer(x[i], ' ');
  writer(x[n - 1], '\n');
}
char memarr[77000000];
void *mem = memarr;
int N, K;
int A[120];
double dp[12000], nx[12000];
int node;
int mp[120][120];
int rev1[1200], rev2[1200];
int main() {
  int i, j, k, x, y, ii, jj, kk;
  int cnt;
  double per;
  double res = 0;
  reader(&N, &K);
  for (i = 0; i < N; i++) reader(A + i);
  node = 0;
  for (i = 0; i < N; i++)
    for (j = i + 1; j < N; j++) {
      mp[i][j] = node;
      rev1[node] = i;
      rev2[node] = j;
      node++;
    }
  for (i = 0; i < node; i++) dp[i] = 0;
  cnt = 0;
  for (x = 0; x < N; x++)
    for (y = x; y < N; y++) cnt++;
  per = 1.0 / cnt;
  while (K--) {
    for (i = 0; i < node; i++) nx[i] = 0;
    for (x = 0; x < N; x++)
      for (y = x; y < N; y++)
        for (k = 0; k < node; k++) {
          ii = i = rev1[k];
          jj = j = rev2[k];
          if (x <= ii && ii <= y) ii = y + x - i;
          if (x <= jj && jj <= y) jj = y + x - j;
          if (ii < jj) {
            kk = mp[ii][jj];
            nx[k] += dp[kk] * per;
          } else {
            kk = mp[jj][ii];
            nx[k] += (1 - dp[kk]) * per;
          }
        }
    for (i = 0; i < node; i++) dp[i] = nx[i];
  }
  for (k = 0; k < node; k++) {
    i = rev1[k];
    j = rev2[k];
    if (A[i] < A[j])
      res += dp[k];
    else
      res += 1 - dp[k];
  }
  writerLn(res);
  return 0;
}
