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