#include <bits/stdc++.h>
using namespace std;
int n;
double cnt;
double solve(vector<int> v, int k) {
  if (k == 0) {
    int inv = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (v[j] < v[i]) ++inv;
      }
    }
    return double(inv);
  }
  double ret = 0.0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> tmp = v;
      reverse(tmp.begin() + i, tmp.begin() + j + 1);
      ret += solve(tmp, k - 1) / cnt;
    }
  }
  return ret;
}
int main() {
  int k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n; ++i)
    for (int j = i; j < n; ++j) ++cnt;
  cout << fixed << setprecision(15) << solve(v, k) << "\n";
  return 0;
}
