#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, k;
int a[200];
double dp[40][40][300];
bool calced[40][40][300];
int get(int l, int r, int x) {
  if (x < l || x > r) return x;
  return r - x;
}
double calc(int x, int y, int k) {
  if (k == 0) {
    if (x < y)
      return 1.0;
    else
      return 0.0;
  }
  double &res = dp[x][y][k];
  if (calced[x][y][k]) return res;
  calced[x][y][k] = 1;
  res = 0;
  double all = n * 1.0 * (n + 1) / 2.0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int nx = x;
      int ny = y;
      if (x >= i && x <= j) nx = j - x + i;
      if (y >= i && y <= j) ny = j - y + i;
      res += calc(nx, ny, k - 1) / all;
    }
  }
  return res;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      double p = calc(i, j, k);
      double q = 1.0 - p;
      if (a[i] > a[j])
        ans += p;
      else
        ans += q;
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}
