#include <bits/stdc++.h>
using namespace std;
int a[32];
int n, k;
double dp[32][32][205];
int main() {
  memset(dp, 0, sizeof(dp));
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (a[i] > a[j]) {
        dp[i][j][0] = 1;
      }
    }
  }
  double prob = (double)2 / (n * (n + 1));
  for (int op = 1; op <= k; ++op) {
    for (int start = 0; start < n; ++start) {
      for (int end = start; end < n; ++end) {
        for (int x = 0; x < n; ++x) {
          for (int y = x; y < n; ++y) {
            int nx = x;
            if (start <= x && x <= end) nx = end - x + start;
            int ny = y;
            if (start <= y && y <= end) ny = start + end - y;
            if (ny >= nx)
              dp[x][y][op] += dp[nx][ny][op - 1] * prob;
            else
              dp[x][y][op] += (1 - dp[ny][nx][op - 1]) * prob;
          }
        }
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) ans += dp[i][j][k];
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}
