#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  long double co_eff = 1.0;
  long double den = (long double)((n * (n + 1)) / 2);
  for (long long i = 1; i <= k; i++) co_eff *= (1.0 / den);
  long double ans = 0;
  function<void(vector<long long> &, long long)> dfs = [&](vector<long long> &p,
                                                           long long x) {
    if (x == k) {
      long double c = 0;
      for (long long i = 0; i < n; i++) {
        for (long long j = i + 1; j < n; j++) {
          if (p[i] > p[j]) c++;
        }
      }
      ans += (co_eff * c);
      return;
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = i; j < n; j++) {
        vector<long long> temp = p;
        reverse(temp.begin() + i, temp.begin() + j + 1);
        dfs(temp, x + 1);
      }
    }
    return;
  };
  vector<long long> p(n);
  for (long long i = 0; i < n; i++) cin >> p[i];
  dfs(p, 0);
  cout << fixed << setprecision(9) << ans;
}
