#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int n, k;
long long sum, cnt;
void _try(int blah) {
  if (blah > k) {
    for (int i = int(0); i <= int(n - 2); i++)
      for (int j = int(i + 1); j <= int(n - 1); j++)
        if (arr[i] > arr[j]) sum++;
    cnt++;
    return;
  }
  for (int i = int(0); i <= int(n - 1); i++)
    for (int j = int(i); j <= int(n - 1); j++) {
      reverse(arr.begin() + i, arr.begin() + j + 1);
      _try(blah + 1);
      reverse(arr.begin() + i, arr.begin() + j + 1);
    }
}
int main(int argc, char *argv[]) {
  cin >> n >> k;
  int number;
  cout << fixed;
  cout.precision(12);
  for (int i = int(0); i <= int(n - 1); i++) {
    cin >> number;
    arr.push_back(number);
  }
  sum = 0, cnt = 0;
  _try(1);
  cout << sum / (double)cnt << endl;
  return EXIT_SUCCESS;
}
