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