#include <bits/stdc++.h>
using namespace std;
int n, k;
double d[1000], d2[1000];
int a[33];
double ans = 0;
const double EPS = 1e-30;
double tran[1000][1000];
vector<pair<int, double> > tv[1000];
void solve() {
  double di = 2.0 / (n * (n + 1));
  int N = n * n;
  for (int i = 0; i < (int)(N); ++i)
    for (int j = 0; j < (int)(N); ++j) tran[i][j] = 0;
  for (int i = 0; i < (int)(N); ++i) {
    int x = i / n;
    int y = i % n;
    for (int l = 0; l < (int)(n); ++l)
      for (int r = l; r < n; ++r) {
        int xx = x, yy = y;
        if (xx >= l && xx <= r) xx = r + l - xx;
        if (yy >= l && yy <= r) yy = r + l - yy;
        tran[i][xx * n + yy] += di;
      }
  }
  for (int i = 0; i < (int)(N); ++i)
    for (int j = 0; j < (int)(N); ++j)
      if (tran[i][j] > EPS) tv[i].push_back(make_pair(j, tran[i][j]));
  for (int times = 0; times < (int)(k); ++times) {
    for (int i = 0; i < (int)(N); ++i) d2[i] = 0;
    for (int i = 0; i < (int)(N); ++i)
      if (d[i] > EPS)
        for (int j = 0; j < (int)(tv[i].size()); ++j)
          d2[tv[i][j].first] += d[i] * tv[i][j].second;
    for (int i = 0; i < (int)(N); ++i) d[i] = d2[i];
    for (int i = 0; i < (int)(N); ++i)
      if (d[i] < EPS) d[i] = 0;
  }
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(i); ++j) ans += d[i * n + j];
  for (int i = 0; i < (int)(N); ++i) tv[i].clear();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  ans = 0;
  for (int i = 0; i < (int)(n * n); ++i) d[i] = 0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = i + 1; j < n; ++j)
      if (a[i] < a[j])
        d[i * n + j] += 1;
      else
        d[j * n + i] += 1;
  solve();
  cout << setprecision(15) << fixed << ans << endl;
  return 0;
}
