#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
int p[N];
int main() {
  int n, inv = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (p[j] > p[i]) inv++;
  cout << (inv & 1 ? (inv - 1) * 2 + 1 : inv * 2);
  return 0;
}
