#include <bits/stdc++.h>
using namespace std;
long long a[100000];
int main() {
  long long n;
  long long cnt = 0;
  scanf("%I64d", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    for (long long j = 0; j < i; j++)
      if (a[j] > a[i]) cnt++;
  }
  cout << (cnt % 2 + (cnt / 2) * 4) << endl;
  return 0;
}
