#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, coun = 0, A[10000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (A[i] > A[j]) {
        coun++;
      }
    }
  }
  if (coun % 2 == 1) {
    printf("%lf\n", 2.0 * coun - 1);
  } else {
    printf("%lf\n", 2.0 * coun);
  }
  return 0;
}
