#include <bits/stdc++.h>
using namespace std;
int n, a[100008];
int c;
void Work() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) {
        c++;
      }
    }
  }
  if (c == 0) {
    printf("0.000000\n");
  } else {
    printf("%d\n", c % 2 + c / 2 * 4);
  }
}
int main() { Work(); }
