#include <bits/stdc++.h>
using namespace std;
int a[110], b[110];
int n, k;
double ans = 0.0;
void reverse(int arr[], int x, int y) {
  for (int i = x; i <= (y + x) / 2; i++) swap(arr[i], arr[y + x - i]);
  return;
}
void dfs(int now[], int cen) {
  if (cen > k) {
    double count = 0.0;
    double tot = n * (n + 1) * 1.0 / 2.0;
    double f = 1.0;
    for (int i = 1; i <= k; i++) f = f * tot;
    ;
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++)
        if (now[i] > now[j]) count = count + 1.0;
    ans = ans + count / f;
    return;
  }
  for (int l = 1; l <= n; l++)
    for (int r = l; r <= n; r++) {
      reverse(now, l, r);
      dfs(now, cen + 1);
      reverse(now, l, r);
    }
  return;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) b[i] = a[i];
  dfs(b, 1);
  printf("%.15f\n", ans);
  return 0;
}
