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