#include <bits/stdc++.h>
using namespace std;
const int maxn = 3100;
int a[maxn];
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 1; j < i; ++j) {
      if (a[j] > a[i]) ans++;
    }
  }
  if (ans & 1)
    ans = (ans - 1) * 2 + 1;
  else
    ans = ans * 2;
  cout << ans << endl;
  return 0;
}
