#include <bits/stdc++.h>
using namespace std;
int mmerge(vector<int>& arr, vector<int>& temp, int left, int mid, int right) {
  int i, j, k;
  int inv_count = 0;
  i = left;
  j = mid;
  k = left;
  while ((i <= mid - 1) && (j <= right)) {
    if (arr[i] <= arr[j])
      temp[k++] = arr[i++];
    else {
      temp[k++] = arr[j++];
      inv_count = inv_count + (mid - i);
    }
  }
  while (i <= mid - 1) temp[k++] = arr[i++];
  while (j <= right) temp[k++] = arr[j++];
  for (i = left; i <= right; i++) arr[i] = temp[i];
  return inv_count;
}
int mSort(vector<int>& arr, vector<int>& temp, int l, int r) {
  int mid, invC = 0;
  if (r > l) {
    mid = (l + r) / 2;
    invC = mSort(arr, temp, l, mid);
    invC += mSort(arr, temp, mid + 1, r);
    invC += mmerge(arr, temp, l, mid + 1, r);
  }
  return invC;
}
int num_inv(vector<int> arr) {
  vector<int> temp(arr.size());
  return mSort(arr, temp, 0, arr.size() - 1);
}
void inv(vector<int>& p, int l, int r) {
  while (l < r) {
    swap(p[l], p[r]);
    l++;
    r--;
  }
  return;
}
int n;
double ppick;
double solve(vector<int> p, int k) {
  if (k == 0) return num_inv(p);
  vector<int> po = p;
  double sum = 0.;
  vector<vector<int> > child;
  for (int r = 0; r < n; ++r) {
    for (int l = 0; l <= r; ++l) {
      inv(p, l, r);
      child.push_back(p);
      p = po;
    }
  }
  for (int i = 0; i < child.size(); i++) {
    sum += ppick * solve(child[i], k - 1);
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  ppick = 2. / (n * (n + 1));
  cout << fixed << setprecision(15) << solve(p, k) << endl;
  return 0;
}
