#include <bits/stdc++.h>
const int mx = 3003;
int a[mx], p[mx * mx];
int main() {
  int inv = 0, n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      if (a[i] > a[j]) ++inv;
  int ans = 0;
  p[1] = 1;
  for (int i = 2; i <= inv; ++i) p[i] = 4 + p[i - 2];
  printf("%d\n", p[inv]);
}
