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