#include <bits/stdc++.h>
using namespace std;
double f[101][101], nf[101][101];
int a[101];
int main() {
  int T, n, i, j, k, m;
  scanf("%d%d", &n, &m);
  m = min(m, 900);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  double p = 2. / n / (n + 1);
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++) f[i][j] = a[i] > a[j];
  for (k = 0; k < m; k++) {
    for (i = 0; i < n; i++)
      for (j = i + 1; j < n; j++) {
        nf[i][j] = 0;
        nf[i][j] += f[i][j] * (i * (i + 1) / 2 + (j - i) * (j - i - 1) / 2 +
                               (n - j) * (n - j - 1) / 2);
        for (int sum = j; sum <= i + n - 1; sum++) {
          int from = max(sum - n + 1, 0);
          int to = min(i, sum - j);
          nf[i][j] += (1 - f[sum - j][sum - i]) * (to - from + 1);
        }
        for (int sum = i; sum <= i + j - 1; sum++) {
          int from = max(sum - j + 1, 0);
          int to = min(i, sum - i);
          nf[i][j] += f[sum - i][j] * (to - from + 1);
        }
        for (int sum = i + j + 1; sum <= j + n - 1; sum++) {
          int from = max(sum - n + 1, i + 1);
          int to = min(j, sum - j);
          nf[i][j] += f[i][sum - j] * (to - from + 1);
        }
      }
    for (i = 0; i < n; i++)
      for (j = i + 1; j < n; j++) f[i][j] = nf[i][j] * p;
  }
  double ans = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) ans += f[i][j];
  printf("%.9lf\n", ans);
  return 0;
}
