#include <bits/stdc++.h>
using namespace std;
int n, arr[3005], inv = 0;
int dp[2][2];
int main() {
  cin >> n;
  for (int j = 1; j <= n; j++) {
    cin >> arr[j];
    for (int i = 1; i < j; i++)
      if (arr[i] > arr[j]) inv++;
  }
  cout << 2 * inv - inv % 2 << endl;
}
