#include <bits/stdc++.h>
using namespace std;
int p[101];
double dp[101][101][201];
bool vis[101][101][201];
int n, k;
int newpos(int l, int r, int x) {
  if (!(l <= x && x <= r)) return x;
  int p = l + r - x;
  assert(l <= p && p <= r);
  return p;
}
double prob(int l, int r, int k) {
  if (k == 0) return l < r;
  if (vis[l][r][k]) return dp[l][r][k];
  vis[l][r][k] = true;
  double pro = 0.0;
  double count = 0.0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int newl = newpos(i, j, l), newr = newpos(i, j, r);
      pro = pro + prob(newl, newr, k - 1);
      count = count + 1.0;
    }
  }
  return dp[l][r][k] = (pro / count);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (p[i] < p[j]) {
        ans += 1.0 - prob(i, j, k);
      } else {
        ans += prob(i, j, k);
      }
    }
  }
  printf("%.20lf\n", ans);
  return 0;
}
