#include <bits/stdc++.h>
using namespace std;
int n, p[5][6];
double solve(int k) {
  double ret = 0;
  if (k == 0) {
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j)
        if (p[0][i] > p[0][j]) ret += 1;
    return ret;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      for (int x = 0; x < i; ++x) p[k - 1][x] = p[k][x];
      for (int x = j + 1; x < n; ++x) p[k - 1][x] = p[k][x];
      for (int x = i; x <= j; ++x) p[k - 1][x] = p[k][i + j - x];
      ret += solve(k - 1);
    }
  }
  return ret / (n * (n + 1) / 2);
}
int main() {
  int k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", &p[k][i]);
  printf("%.12f\n", solve(k));
  return 0;
}
