#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int a[20100];
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j < i; j++)
      if (a[j] > a[i]) ans++;
  }
  if (ans % 2 == 0)
    ans = ans * 2;
  else
    ans = ans / 2 * 4 + 1;
  printf("%d\n", ans);
}
