#include <bits/stdc++.h>
using namespace std;
const int mx[4] = {1, -1, 0, 0};
const int my[4] = {0, 0, 1, -1};
const int Nmax = 100300;
double a[Nmax];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int m = 0;
  for (int i = 1; i <= n - 1; i++)
    for (int j = i + 1; j <= n; j++)
      if (a[i] > a[j]) m++;
  n = m;
  m = 0;
  if (n & 1) n--, ++m;
  m += 2 * n;
  cout << m << endl;
  return 0;
}
