#include <bits/stdc++.h>
using namespace std;
int n, K;
vector<int> arr;
int count(vector<int> &a) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += (a[i] > a[j]);
    }
  }
  return ans;
}
long double solve(vector<int> &a, int k) {
  if (k == K) {
    return count(a);
  }
  long double ret = 0;
  long double prob = 2.0 / (n * (n + 1));
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      vector<int> tmp(a.begin(), a.end());
      reverse(tmp.begin() + i, tmp.begin() + j + 1);
      ret += prob * solve(tmp, k + 1);
    }
  }
  return ret;
}
int main() {
  cin >> n >> K;
  arr.resize(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << setprecision(10) << fixed << solve(arr, 0) << endl;
}
