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