#include <bits/stdc++.h>
using namespace std;
int n, sum, p[3010];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    for (int j = 1; j < i; ++j)
      if (p[j] > p[i]) sum++;
  }
  if (sum % 2 == 0)
    cout << sum * 2 << endl;
  else
    cout << sum * 2 - 1 << endl;
  return 0;
}
