#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3030;
int a[MAXN];
double dp[MAXN][MAXN];
double calc(int n) {
  double res = pow(0.5, n);
  double sum = 0.0;
  for (int i = 1; i <= n; ++i) {
    sum += pow(0.25 * (1.0 * n + i), i);
  }
  return res * sum;
}
int main(int argc, char **argv) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  int inv = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      if (a[j] > a[i]) {
        ++inv;
      }
    }
  }
  cout << ((inv & 1) ? (2 * inv - 1) : (inv * 2)) << endl;
  return 0;
}
