#include <bits/stdc++.h>
using namespace std;
int const maxn = 120;
int const maxk = 950;
int p[maxn];
double *ans[maxn];
double *next_ans[maxn];
void init(int n) {
  for (int i = 0; i < (int)(maxn); ++i)
    for (int j = 0; j < (int)(maxn); ++j) ans[i][j] = -50000.0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = i + 1; j < n; ++j) ans[i][j] = p[i] > p[j] ? 1.0 : 0.0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < (int)(maxn); ++i) {
    ans[i] = new double[maxn];
    next_ans[i] = new double[maxn];
  }
  for (int i = 0; i < (int)(n); ++i) {
    cin >> p[i];
  }
  init(n);
  if (k > maxk) k = maxk;
  double koef = 2.0 / (n * (n + 1));
  for (int step = 0; step < (int)(k); ++step) {
    for (int i = 0; i < (int)(n); ++i)
      for (int j = i + 1; j < n; ++j) {
        int cnt_mid = j - i;
        int toleft = n - j;
        next_ans[i][j] =
            ans[i][j] *
            ((cnt_mid * (cnt_mid - 1) + i * (i + 1) + toleft * (toleft - 1)) /
             2);
        for (int sum = j; sum < i + n; ++sum) {
          int left = sum - n + 1 > 0 ? sum - n + 1 : 0;
          int right = (sum - j > i ? i : sum - j) + 1;
          next_ans[i][j] += (1.0 - ans[sum - j][sum - i]) * (right - left);
        }
        for (int sum = i; sum < i + j; ++sum) {
          int left = sum - j + 1 > 0 ? sum - j + 1 : 0;
          int right = (sum - i > i ? i : sum - i) + 1;
          next_ans[i][j] += ans[sum - i][j] * (right - left);
        }
        for (int sum = i + j + 1; sum < n + j; ++sum) {
          int left = sum - n + 1 <= i ? i + 1 : sum - n + 1;
          int right = (sum - j > j ? j : sum - j) + 1;
          next_ans[i][j] += ans[i][sum - j] * (right - left);
        }
        next_ans[i][j] *= koef;
      }
    for (int i = 0; i < (int)(n); ++i) swap(ans[i], next_ans[i]);
  }
  double ret = 0.0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = i + 1; j < n; ++j) ret += ans[i][j];
  cout << ret << endl;
  return 0;
}
