#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  int n, k, a[6] = {}, p = 1, o = 0, z = 0;
  pair<int, int> b[21] = {};
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++) b[o++] = {j, i};
  for (int i = 0; i < k; i++) p *= o;
  for (int i = 0; i < p; i++) {
    int c[6] = {}, d = i;
    for (int j = 0; j < n; j++) c[j] = a[j];
    for (int j = 0; j < k; j++) {
      int l = b[d % o].first, r = b[d % o].second;
      reverse(c + l, c + r + 1);
      d /= o;
    }
    for (int j = 0; j < n; j++)
      for (int l = 0; l < j; l++)
        if (c[l] > c[j]) z++;
  }
  cout << setprecision(13) << 1.0 * z / p;
}
