#include <bits/stdc++.h>
using namespace std;
int n;
bool ok[3001];
int main() {
  int x, cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    for (int j = x + 1; j <= n; j++)
      if (ok[j]) cnt++;
    ok[x] = true;
  }
  if (cnt & 1)
    cnt = cnt * 2 - 1;
  else
    cnt = cnt * 2;
  printf("%f\n", (float)cnt);
  return 0;
}
