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