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