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