#include <bits/stdc++.h>
int a[3000];
long long go(int n) {
  if (n == 0) {
    return 0;
  }
  if (n == 1) {
    return 1;
  }
  long long f0 = 0, f1 = 1, fn = 0;
  for (int i = 2; i <= n; ++i) {
    fn = 4 + f0;
    f0 = f1;
    f1 = fn;
  }
  return fn;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int inv = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      inv += a[i] > a[j];
    }
  }
  printf("%lld\n", go(inv));
  return 0;
}
