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