#include <bits/stdc++.h>
using namespace std;
int n, k;
int cnt = 0;
int sum = 0;
void tryIt(int cur[], int k) {
  if (k == 0) {
    cnt++;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (cur[i] > cur[j]) sum++;
      }
    }
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      for (int kk = 0; kk <= (j - i) / 2; kk++) {
        int tmp = cur[i + kk];
        cur[i + kk] = cur[j - kk];
        cur[j - kk] = tmp;
      }
      tryIt(cur, k - 1);
      for (int kk = 0; kk <= (j - i) / 2; kk++) {
        int tmp = cur[i + kk];
        cur[i + kk] = cur[j - kk];
        cur[j - kk] = tmp;
      }
    }
  }
}
int main() {
  int cur[10];
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> cur[i];
  tryIt(cur, k);
  cout << setprecision(20) << (double)(sum) / (double)(cnt);
  return 0;
}
