#include <bits/stdc++.h>
using namespace std;
int a[3005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) cnt += (a[i] > a[j]);
  if (cnt & 1)
    cout << 2 * cnt - 1 << endl;
  else
    cout << 2 * cnt << endl;
  return 0;
}
