#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, k;
int a[N];
double f[N][N], nf[N][N];
int MAIN() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (k > 1000) {
    k = 1000;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      f[i][j] = (a[i] > a[j]);
    }
  }
  double p = 2. / n / (n + 1);
  for (int step = 0; step < k; ++step) {
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        nf[i][j] = 0.;
        nf[i][j] += f[i][j] * 1. *
                    ((i + 1) * i / 2 + (j - i) * (j - i - 1) / 2 +
                     (n - j) * (n - j - 1) / 2);
        for (int sum = j; sum <= i + n - 1; ++sum) {
          int from = (sum - n + 1 > 0) ? sum - n + 1 : 0;
          int to = (i < sum - j) ? 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 = (sum - j + 1 > 0) ? sum - j + 1 : 0;
          int to = (i < sum - i) ? i : sum - i;
          nf[i][j] += f[sum - i][j] * (to - from + 1);
        }
        for (int sum = i + 1 + j; sum <= j + n - 1; ++sum) {
          int from = (sum - n + 1 >= i + 1) ? sum - n + 1 : i + 1;
          int to = (j < sum - j) ? j : sum - j;
          nf[i][j] += f[i][sum - j] * (to - from + 1);
        }
        nf[i][j] *= p;
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        f[i][j] = nf[i][j];
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      ans += f[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  return MAIN();
}
