#include <bits/stdc++.h>
using namespace std;
const long long maxn = 45;
const long long maxk = 205;
double dp[maxk][maxn][maxn];
long long a[maxn];
long long n, x;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  double N = n * (n + 1) / 2;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      if (i - j && i > j) dp[0][i][j] = 1;
  for (long long i = 1; i <= x; i++) {
    for (long long j = 0; j < n; j++)
      for (long long k = 0; k < n; k++)
        if (j - k)
          for (long long l = 0; l < n; l++)
            for (long long r = l; r < n; r++) {
              long long j1 = j, k1 = k;
              if (l <= j && j <= r) j1 = r - (j - l);
              if (l <= k && k <= r) k1 = r - (k - l);
              dp[i][j][k] += dp[i - 1][j1][k1] / N;
            }
  }
  double res = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++)
      if (a[j] > a[i])
        res += dp[x][i][j];
      else
        res += dp[x][j][i];
  }
  cout << fixed << setprecision(12) << res << '\n';
  return 0;
}
