#include <bits/stdc++.h>
using namespace std;
void testGen() {
  freopen("biginput1.txt", "w", stdout);
  fclose(stdout);
}
int p[110], n, k, pos[110];
int totalOps;
double pr[2][110][110];
int getPos(int i, int l, int r) {
  if (i < l || i > r) {
    return i;
  }
  return r - i + l;
}
int countOp(int s, int i, int j) {
  int l = i, r = s - l;
  if (!(r >= j && r <= n)) {
    r = j;
    l = s - r;
    if (!(l <= i && l >= 1)) {
      return 0;
    }
  }
  return min(l, n - r + 1);
  ;
}
int countOpSwap1(int i, int j, int i2) {
  if (i > i2) {
    return countOpSwap1(i2, j, i);
  }
  return min(i, j - i2);
}
int countOpSwap2(int i, int j, int j2) {
  if (j2 > j) {
    return countOpSwap2(i, j2, j);
  }
  return min(j2 - i, n - j + 1);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    pos[p[i]] = i;
  }
  totalOps = n * (n + 1) / 2;
  memset(pr, 0, sizeof(pr));
  int cur = 0, next = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      pr[cur][i][j] = p[i] > p[j] ? 1 : 0;
    }
  }
  for (auto repeat_var = 0; repeat_var < k; ++repeat_var) {
    memset(pr[next], 0, sizeof(pr[next]));
    for (int i = 1; i < n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int i2 = 1; i2 < j; ++i2) {
          int cnt = countOpSwap1(i, j, i2);
          pr[next][i2][j] += pr[cur][i][j] * ((double)cnt / totalOps);
        }
        for (int j2 = i + 1; j2 <= n; ++j2) {
          int cnt = countOpSwap2(i, j, j2);
          pr[next][i][j2] += pr[cur][i][j] * ((double)cnt / totalOps);
        }
        pr[next][i][j] += ((double)(i - 1) * i / 2 + (n - j) * (n - j + 1) / 2 +
                           (j - i - 1) * (j - i) / 2) *
                          pr[cur][i][j] / totalOps;
        for (int j2 = 1; j2 <= n; ++j2) {
          int i2 = j2 + (j - i);
          if (i2 > n) break;
          int sum_r_l = j2 + j;
          int cnt = countOp(sum_r_l, i, j);
          assert(j2 < i2);
          pr[next][j2][i2] += (1 - pr[cur][i][j]) * ((double)cnt / totalOps);
        }
      }
    }
    cur = 1 - cur;
    next = 1 - next;
  }
  double ret = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      ret += pr[cur][i][j];
    }
  }
  printf("%.10lf", ret);
  return 0;
}
