#include <bits/stdc++.h>
using namespace std;
int A[666];
double dp[266][32][32];
int main() {
  int n, k, i, l, j, t, r;
  cin >> n >> k;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (i = 1; i <= n; ++i) cin >> A[i];
  double cn = 1.0 / ((n * (n + 1)) / 2);
  for (t = 1; t <= k; ++t)
    for (i = 1; i <= n; ++i)
      for (j = i + 1; j <= n; ++j) {
        for (l = 1; l <= n; ++l)
          for (r = l; r <= n; ++r) {
            int p1 = i, p2 = j;
            if (i >= l && i <= r) p1 = r - (i - l);
            if (j >= l && j <= r) p2 = l + (r - j);
            if (p1 > p2)
              dp[t][i][j] += (1.0 - dp[t - 1][p2][p1]) * cn;
            else
              dp[t][i][j] += dp[t - 1][p1][p2] * cn;
          }
      }
  double result = 0;
  for (i = 1; i <= n; ++i)
    for (j = i + 1; j <= n; ++j)
      if (A[i] < A[j])
        result += dp[k][i][j];
      else
        result += (1.0 - dp[k][i][j]);
  cout << fixed;
  cout << setprecision(10);
  cout << result << '\n';
  return 0;
}
