#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (1) {
    a = a % b;
    if (a == 0) return b;
    b = b % a;
    if (b == 0) return a;
  }
}
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int a[3000];
    for (int i = 0; i < n; i++) cin >> a[i];
    int tot = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < (n - 1); j++) {
        if (a[j + 1] < a[j]) {
          int temp = a[j];
          a[j] = a[j + 1];
          a[j + 1] = temp;
          tot++;
        }
      }
    }
    if (tot & 1)
      cout << (2 * (tot - 1) + 1) << endl;
    else
      cout << (2 * (tot - 1) + 2) << endl;
  }
  return 0;
}
