#include <bits/stdc++.h>
using namespace std;
int n, m, p[3072];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", p + i);
    for (int j = 1; j < i; j++)
      if (p[j] > p[i]) ++m;
  }
  if (m & 1) {
    m <<= 1;
    --m;
  } else
    m <<= 1;
  printf("%d", m);
  return 0;
}
