#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[500];
int original[500];
int total_inversions = 0;
int total_count = 0;
void f(int remaining) {
  if (remaining == 0) {
    int inversions = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (arr[i] > arr[j]) {
          inversions++;
        }
      }
    }
    total_inversions += inversions;
    total_count++;
    return;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      for (int k = i; k <= (i + j) / 2; ++k) {
        int temp = arr[k];
        arr[k] = arr[j - k + i];
        arr[j - k + i] = temp;
      }
      f(remaining - 1);
      for (int k = i; k <= (i + j) / 2; ++k) {
        int temp = arr[k];
        arr[k] = arr[j - k + i];
        arr[j - k + i] = temp;
      }
    }
  }
}
int main() {
  int kk;
  scanf("%d %d", &n, &kk);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
    original[i] = arr[i];
  }
  f(kk);
  cout << setprecision(16) << (double)total_inversions / (double)total_count
       << endl;
  return 0;
}
