#include <bits/stdc++.h>
using namespace std;
const int N = 3500;
int n, a[N], w, q;
int main() {
  cin >> n;
  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[i] > a[j]) q++;
  w = q * 2;
  if (q % 2 == 1) w--;
  cout << w;
}
