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