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