#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
#pragma GCC target("avx,avx2")
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 35, M = 205;
double p, ans, f[M][N][N];
int a[N], n, m;
int rev(int x, int l, int r) {
  if (x < l || x > r) return x;
  return l + r - x;
}
signed main() {
  read(n, m);
  for (int i = 1; i <= n; i++) read(a[i]);
  p = 2.0 / (n * (n + 1));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[0][i][j] = a[i] > a[j];
  for (int i = 1; i <= m; i++)
    for (int x = 1; x <= n; x++)
      for (int y = 1; y <= n; y++)
        for (int l = 1; l <= n; l++)
          for (int r = l; r <= n; r++)
            f[i][x][y] += p * f[i - 1][rev(x, l, r)][rev(y, l, r)];
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) ans += f[m][i][j];
  printf("%.10lf", ans);
}
