#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1, ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
pair<int, int> a[40];
int num[10];
int b[10];
int n, m;
int op[5];
long long ans = 0;
long long mu = 0;
int top;
void dfs(int pos, int cur) {
  if (cur == m + 1) {
    mu++;
    for (int i = 1; i <= int(n); i++) b[i] = num[i];
    for (int i = 1; i <= int(m); i++) {
      int x = a[op[i]].first, y = a[op[i]].second;
      for (int i = x; i <= (x + y) / 2; i++) swap(b[i], b[y - (i - x)]);
    }
    for (int i = 1; i <= int(n); i++)
      for (int j = 1; j <= int(i - 1); j++)
        if (b[i] < b[j]) ans++;
    return;
  }
  for (int i = pos; i <= top; i++) {
    op[cur] = i;
    dfs(pos, cur + 1);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= int(n); i++) RD(num[i]);
  top = 0;
  for (int i = 1; i <= int(n); i++)
    for (int j = 1; j <= int(i); j++) {
      a[++top] = pair<int, int>(j, i);
    }
  dfs(1, 1);
  printf("%.12f\n", ans / (double)mu);
}
