#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[101];
int pp[101];
long long binom[101][101];
void init(int n, int k) {
  for (int i = 0; i <= n; i++) binom[i][0] = 1;
  for (int j = 1; j <= k; j++) binom[0][j] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
    }
  }
}
double exp_val = 0.0;
inline void obrni(int l, int r) {
  for (int i = l; i <= r; i++) pp[i] = p[i];
  for (int i = l, j = r; i <= r; i++, j--) {
    p[i] = pp[j];
  }
}
inline int cnt_inv() {
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (p[i] > p[j]) ret++;
    }
  }
  return ret;
}
double ways = 0.0;
void generate(int idd) {
  if (idd == k) {
    exp_val += cnt_inv();
    ways++;
    return;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      obrni(i, j);
      generate(idd + 1);
      obrni(i, j);
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  generate(0);
  printf("%.10lf\n", exp_val / ways);
  return 0;
}
