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