#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int inv = 0;
  int A[n + 1];
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (A[j] < A[i]) inv++;
  cout << 2 * inv - inv % 2;
}
