#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
int n, k, tot;
vector<int> rev(int i, int j, vector<int> arr) {
  while (i < j) swap(arr[i++], arr[j--]);
  return arr;
}
map<vector<int>, double> mp[10];
double bt(int lef, vector<int> arr) {
  if (mp[lef].find(arr) != mp[lef].end()) return mp[lef][arr];
  if (lef == 0) {
    int ret = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (arr[i] > arr[j]) ret++;
    cout << "";
    ;
    return mp[lef][arr] = ret;
  }
  double ret = 0;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      double prob = 1. / tot;
      arr = rev(i, j, arr);
      ret += prob * bt(lef - 1, arr);
      arr = rev(i, j, arr);
    }
  return mp[lef][arr] = ret;
}
int main() {
  cin >> n >> k;
  int x;
  vector<int> a;
  tot = (n * (n + 1)) / 2;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  printf("%.10lf\n", bt(k, a));
  return 0;
}
