#include <bits/stdc++.h>
using namespace std;
char IO;
int rd() {
  int s = 0, f = 0;
  while (!isdigit(IO = getchar()))
    if (IO == '-') f = 1;
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 3e3 + 10, P = 1e9 + 7;
int n, m, p;
int a[N];
double dp[N * N];
int main() {
  n = rd();
  for (int i = 1, iend = n; i <= iend; ++i) {
    a[i] = rd();
    for (int j = 1, jend = i; j <= jend; ++j)
      if (a[j] > a[i]) m++;
  }
  dp[0] = 0;
  if (m & 1) {
    dp[1] = 1;
    for (int i = 2, iend = m; i <= iend; ++i) {
      dp[i] = dp[i - 2] + 4;
    }
    printf("%.6lf\n", dp[m]);
  } else {
    for (int i = 2, iend = m; i <= iend; ++i) {
      dp[i] = dp[i - 2] + 4;
    }
    printf("%.6lf\n", dp[m]);
  }
}
