#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 3030;
int val[MAXN];
int N;
int main() {
  while (scanf("%d", &N) != EOF) {
    for (int i = 1; i <= N; i++) scanf("%d", &val[i]);
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j < i; j++)
        if (val[i] < val[j]) cnt++;
    }
    if (cnt & 1)
      printf("%d\n", cnt * 2 - 1);
    else
      printf("%d\n", cnt * 2);
  }
  return 0;
}
