#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
template <class T>
T sqr(T a) {
  return a * a;
}
const int MAXN = 4;
int n, k;
int cnt[100];
int a[MAXN];
void rev(int l, int r) {
  int k = r - l + 1;
  for (int i = 0; i < (k >> 1); ++i) swap(a[l + i], a[r - i]);
}
int invCount() {
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[i] > a[j]) ++res;
    }
  }
  return res;
}
void rec(int k) {
  if (k == 0) {
    ++cnt[invCount()];
    return;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      rev(i, j);
      rec(k - 1);
      rev(i, j);
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  rec(k);
  double res = 0;
  int sum = 0;
  for (int i = 0; i < 100; ++i) sum += cnt[i];
  for (int i = 0; i < 100; ++i) res += i * cnt[i] * 1.0 / sum;
  printf("%.15lf\n", res);
  return 0;
}
