#include <bits/stdc++.h>
using namespace std;
int n;
int tree[3000 + 2] = {0};
int read(int arr[], int maxval, int idx) {
  int ret = 0;
  while (idx > 0) {
    ret += arr[idx];
    idx -= idx & -idx;
  }
  return ret;
}
void update(int arr[], int maxval, int idx, int val) {
  while (idx <= maxval) {
    arr[idx] += val;
    idx += idx & -idx;
  }
}
int inv;
void in() {
  cin >> n;
  int t;
  inv = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    inv += read(tree, n, t - 1);
    update(tree, n, t, 1);
  }
  inv = n * (n - 1) / 2 - inv;
}
int x[3000 * 3000 + 2];
void solve() {
  x[0] = 0;
  x[1] = 1;
  for (int i = 2; i <= inv; i++) x[i] = x[i - 2] + 4;
  cout << x[inv] << endl;
}
int main() {
  in();
  solve();
  return 0;
}
