#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
const int inf = 0x3f3f3f3f;
int n, a[N], c[N];
double num[N];
int ABS(int x) { return max(x, -x); }
int lowbit(int x) { return x & -x; }
void modify(int x) {
  while (x <= n) {
    ++c[x];
    x += lowbit(x);
  }
}
int sum(int x) {
  int ret = 0;
  while (x > 0) {
    ret += c[x];
    x -= lowbit(x);
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cnt += i - 1 - sum(a[i]);
    modify(a[i]);
  }
  int ans;
  if (cnt % 2)
    ans = cnt * 2 - 1;
  else
    ans = cnt * 2;
  printf("%d\n", ans);
  return 0;
}
