#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> nums;
int count_inversions(vector<int>& v) {
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (v[i] > v[j]) sum++;
    }
  }
  return sum;
}
double cnt_exp(vector<int>& v, int rem, double pr_init) {
  if (rem == 0) {
    return count_inversions(v) * pr_init;
  }
  int nn = n;
  --nn;
  int variants = nn * (nn + 1) / 2;
  double prob = 1.0 / (n + variants);
  prob *= pr_init;
  double expected = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> cp(v);
      reverse(cp.begin() + i, cp.begin() + j + 1);
      expected += cnt_exp(cp, rem - 1, prob);
    }
  }
  return expected;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    nums.push_back(tmp);
  }
  double ans = cnt_exp(nums, k, 1.0);
  cout << fixed << setprecision(12) << ans << '\n';
}
