#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 10;
int n, k;
int a[N], b[N];
int ans1, ans2;
void f(int step, int arr[]) {
  if (step == k) {
    ans2++;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (arr[i] > arr[j]) ans1++;
      }
    }
    return;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      reverse(arr + i, arr + j + 1);
      f(step + 1, arr);
      reverse(arr + i, arr + j + 1);
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  f(0, b);
  cout.precision(20);
  double l = (double)((double)ans1 / (double)ans2);
  cout << l;
  return 0;
}
