#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[33], pos[33];
double dp[33][33], d[33][33];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      dp[i][j] = 1;
    }
  }
  int tot = n * (n + 1) / 2;
  for (int step = 1; step <= k; step++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (i == j) continue;
        for (int l = 1; l <= n; l++) {
          for (int r = l; r <= n; r++) {
            int x = i, y = j;
            if (x >= l && x <= r) {
              x = r - (x - l);
            }
            if (y >= l && y <= r) {
              y = r - (y - l);
            }
            d[i][j] += dp[x][y];
          }
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dp[i][j] = d[i][j] / tot;
        d[i][j] = 0;
      }
    }
  }
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] > a[j])
        ans += dp[i][j];
      else
        ans += 1 - dp[i][j];
    }
  }
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}
