#include <bits/stdc++.h>
using namespace std;
int mc, n, arr[3010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; j++) {
      if (arr[j] < arr[i]) ++mc;
    }
  cout << (mc / 2) * 4 + (mc & 1);
};
