#include <bits/stdc++.h>
using namespace std;
map<vector<int>, int> int_perm;
map<int, vector<int> > perm_int;
vector<int> inv;
double dp[5][1000];
void rev(vector<int> &a, int l, int r) {
  while (l < r) {
    swap(a[l], a[r]);
    l++;
    r--;
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 1; i <= n; i++) a.push_back(i);
  int N = 0;
  do {
    int_perm[a] = N;
    perm_int[N] = a;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++)
        if (a[i] > a[j]) cnt++;
    }
    inv.push_back(cnt);
    N++;
  } while (next_permutation(a.begin(), a.end()));
  int K = n * (n + 1) / 2;
  for (int i = 0; i < N; i++) {
    dp[0][i] = inv[i];
  }
  for (int q = 1; q <= k; q++) {
    for (int p = 0; p < N; p++) {
      a = perm_int[p];
      for (int i = 0; i < n; i++)
        for (int j = i; j < n; j++) {
          rev(a, i, j);
          dp[q][p] += dp[q - 1][int_perm[a]];
          rev(a, i, j);
        }
      dp[q][p] /= K;
    }
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << fixed << setprecision(9) << dp[k][int_perm[a]];
}
