#include <bits/stdc++.h>
using namespace std;
class C_ {};
template <typename T>
C_& operator<<(C_& __m, const T& __s) {
  if (!1) cerr << "\E[91m" << __s << "\E[0m";
  return __m;
}
C_ merr;
struct __s {
  __s() {
    if (1) {
      ios_base::Init i;
      cin.sync_with_stdio(0);
      cin.tie(0);
    }
  }
  ~__s() {
    merr << "Execution time: " << (double)clock() / CLOCKS_PER_SEC << " s.\n";
  }
} __S;
map<vector<int>, long double> mp[11];
vector<int> A;
int main() {
  int n, k;
  vector<pair<int, int> > V;
  long double ans = 0.0;
  cin >> n >> k;
  A.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      V.push_back(make_pair(l, r));
      reverse(A.begin() + l, A.begin() + r + 1);
      mp[0][A] += 2.0L / (n * (n + 1));
      reverse(A.begin() + l, A.begin() + r + 1);
    }
  }
  for (int kk = 1; kk < k; kk++) {
    for (map<vector<int>, long double>::const_iterator it = mp[kk - 1].begin();
         it != mp[kk - 1].end(); ++it) {
      vector<int> v = it->first;
      for (int i = 0; i < (int)V.size(); i++) {
        int l = V[i].first, r = V[i].second;
        reverse(v.begin() + l, v.begin() + r + 1);
        mp[kk][v] += it->second * 1.0L / V.size();
        reverse(v.begin() + l, v.begin() + r + 1);
      }
    }
  }
  for (map<vector<int>, long double>::const_iterator it = mp[k - 1].begin();
       it != mp[k - 1].end(); ++it) {
    vector<int> v = it->first;
    int inv = 0;
    for (int i = 0; i < (int)v.size(); i++) {
      for (int j = i + 1; j < (int)v.size(); j++) {
        if (v[i] > v[j]) inv++;
      }
    }
    ans += inv * it->second;
  }
  cout << fixed << setprecision(15) << ans << '\n';
  return 0;
}
