#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 30 + 10, M = 200 + 10;
int n, m, a[N];
double dp[N][N][M], denom, res;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  denom = (n + 1) * (n + 1 - 1) / 2;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < i; j++) dp[j][i][0] = a[j] > a[i];
  }
  for (int k = 1; k <= m; k++)
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        for (int l = 0; l < n; l++)
          for (int r = l; r < n; r++) {
            int pi = i, pj = j;
            if (l <= i && i <= r) pi = r - (i - l);
            if (l <= j && j <= r) pj = r - (j - l);
            if (pi < pj)
              dp[i][j][k] += dp[pi][pj][k - 1] / denom;
            else
              dp[i][j][k] += (1.0 - dp[pj][pi][k - 1]) / denom;
          }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) res += dp[i][j][m];
  cout << fixed << setprecision(10) << res << endl;
  return 0;
}
