#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 0, k, a[100100], b[100100];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    a[b[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int j = a[i];
    while (j > i - 1) {
      swap(b[j], b[j - 1]);
      a[b[j]] = j;
      a[b[j - 1]] = j - 1;
      j--;
      m++;
    }
  }
  cout << max(0, m * 2 - m % 2) << '\n';
  return 0;
}
