#include <bits/stdc++.h>
using namespace std;
int a[2010];
int main() {
  int i;
  int n, cnt;
  while (~scanf("%d", &n)) {
    cnt = 0;
    for (i = 0; i < n; ++i) scanf("%d", a + i);
    for (int i = n - 1; i >= 0; --i) {
      for (int j = 0; j < i; ++j) {
        if (a[i] < a[j]) ++cnt;
      }
    }
    printf("%.6lf\n", (double)((cnt & 1) ? (cnt << 1) - 1 : (cnt << 1)));
  }
  return 0;
}
