#include <bits/stdc++.h>
using namespace std;
int n;
double ans = 0;
void calc(vector<int> arr, int d, double p) {
  if (d == 0) {
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < i; ++j) {
        if (arr[j] > arr[i]) {
          tmp++;
        }
      }
    }
    ans += double(tmp) * p;
    return;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> xxx = arr;
      reverse(xxx.begin() + min(i, j), xxx.begin() + max(i, j) + 1);
      calc(xxx, d - 1, p / (n * (n + 1) / 2));
    }
  }
}
int main() {
  int dep;
  cin >> n >> dep;
  vector<int> vec(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &vec[i]);
  }
  calc(vec, dep, 1);
  printf("%.10lf\n", ans);
  return 0;
}
