#include <bits/stdc++.h>
using namespace std;
int a[110];
int n;
long long rev;
long long cnt;
void f(int d) {
  if (d == 0) {
    ++cnt;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        if (a[i] > a[j]) {
          ++rev;
        }
      }
    }
    return;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      reverse(a + i, a + j + 1);
      f(d - 1);
      reverse(a + i, a + j + 1);
    }
  }
}
int main() {
  int k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  f(k);
  printf("%.10lf\n", 1.0 * rev / cnt);
  return 0;
}
