#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int a[maxn];
int main() {
  int n, cnt, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  cnt = 0;
  for (i = 2; i <= n; ++i)
    for (j = 1; j < i; ++j)
      if (a[j] > a[i]) cnt++;
  if (cnt % 2 == 0)
    cnt *= 2;
  else
    cnt = cnt * 2 - 1;
  printf("%d.000000\n", cnt);
  return 0;
}
