#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const double pi = acos(-1.0);
const int size = 10 * 1000;
const int lsize = 10 * 1000 * 1000;
int p[size];
double ans[lsize];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i];
  int inv = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) inv += (p[i] > p[j]);
  if (inv == 0)
    cout << 0 << endl;
  else {
    if (inv % 2 == 0)
      cout << inv * 2 << endl;
    else
      cout << inv * 2 - 1 << endl;
  }
  return 0;
}
