#include <bits/stdc++.h>
using namespace std;
int n, p[3001], inv;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", p + i);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j)
      if (p[j] > p[i]) ++inv;
  }
  printf("%d\n", (inv <<= 1) & 2 ? inv - 1 : inv);
}
