#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
int n, k;
int mas[30];
int was[30][30][201];
double d[30][30][201];
double di(int x, int y, int r) {
  if (!r) return (x > y);
  if (was[x][y][r]) return d[x][y][r];
  was[x][y][r] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (x <= j && x >= i && y >= i && y <= j) {
        d[x][y][r] += di(i + j - x, i + j - y, r - 1);
        continue;
      }
      if (i <= x && x <= j && (y > j || y < i)) {
        d[x][y][r] += di(i + j - x, y, r - 1);
        continue;
      }
      if ((x < i || x > j) && i <= y && y <= j) {
        d[x][y][r] += di(x, i + j - y, r - 1);
        continue;
      }
      d[x][y][r] += di(x, y, r - 1);
    }
  }
  return d[x][y][r] = d[x][y][r] * 2.0 / (n * (n + 1));
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> mas[i];
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (mas[i] > mas[j])
        ans += (1 - di(i, j, k));
      else
        ans += di(i, j, k);
    }
  }
  printf("%0.11f", ans);
}
