#include <bits/stdc++.h>
int A[3005], N, x;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j < N; j++) x += A[i] > A[j];
  printf("%d", x % 2 ? 2 * x - 1 : 2 * x);
}
