#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int N = (int)1e5;
const int MODULO = (int)1e9 + 7;
int a[105];
int n, k;
double big_ans;
int ver = 1;
void solve(int cnt) {
  if (cnt == 0) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (a[i] > a[j]) ans++;
      }
    }
    big_ans += (double)ans / ver;
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      reverse(a + i, a + j + 1);
      solve(cnt - 1);
      reverse(a + i, a + j + 1);
    }
  }
}
void task() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int t_ver = n * (n + 1) / 2;
  for (int i = 0; i < k; i++) {
    ver *= t_ver;
  }
  if (ver != 0) solve(k);
  cout << setprecision(10) << big_ans;
}
int main() {
  task();
  return 0;
}
