#include <bits/stdc++.h>
using namespace std;
const int NMAX = 105;
int n, k, a[NMAX];
long long nr, sol;
long double ss;
inline int Calc() {
  int i, j, cnt = 0;
  for (i = 1; i <= n; i++)
    for (j = i - 1; j >= 1; j--)
      if (a[i] < a[j]) cnt++;
  return cnt;
}
inline void Back(int pas) {
  if (pas == k + 1) {
    nr++;
    sol += Calc();
  } else
    for (int i = 1; i <= n; i++)
      for (int j = i; j <= n; j++) {
        int aux = (j - i + 1) >> 1;
        for (int l = 1; l <= aux; l++) swap(a[i + l - 1], a[j - l + 1]);
        Back(pas + 1);
        for (int l = 1; l <= aux; l++) swap(a[i + l - 1], a[j - l + 1]);
      }
}
int main() {
  int i;
  cin.sync_with_stdio(false);
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  Back(1);
  ss = (1.0 * sol) / (1.0 * nr);
  cout << setprecision(12) << fixed;
  cout << ss << "\n";
  return 0;
}
