#include <bits/stdc++.h>
using namespace std;
int n, cnt, a;
struct BIT {
  int c[3005];
  BIT() { memset(c, 0, sizeof c); }
  void add(int x, int v) {
    while (x) c[x] += v, x &= x - 1;
  }
  int ask(int x) {
    int r = 0;
    while (x <= n) r += c[x], x += x & -x;
    return r;
  }
} an;
int main() {
  cin >> n;
  for (register int q(1); q <= n; ++q) {
    scanf("%d", &a);
    cnt += an.ask(a);
    an.add(a, 1);
  }
  if (cnt == 0) {
    puts("0");
    return 0;
  }
  --cnt;
  cout << (cnt % 2 == 0 ? 2 * cnt : 2 * cnt + 1) + 1;
  return 0;
}
