Problem: You are given a permutation of integers from 1 to n. Exactly once you apply the following operation to this permutation: pick a random segment and shuffle its elements. Formally:

  1. Pick a random segment (continuous subsequence) from l to r. All <image> segments are equiprobable. 
  2. Let k = r - l + 1, i.e. the length of the chosen segment. Pick a random permutation of integers from 1 to k, p1, p2, ..., pk. All k! permutation are equiprobable. 
  3. This permutation is applied to elements of the chosen segment, i.e. permutation a1, a2, ..., al - 1, al, al + 1, ..., ar - 1, ar, ar + 1, ..., an is transformed to a1, a2, ..., al - 1, al - 1 + p1, al - 1 + p2, ..., al - 1 + pk - 1, al - 1 + pk, ar + 1, ..., an. 



Inversion if a pair of elements (not necessary neighbouring) with the wrong relative order. In other words, the number of inversion is equal to the number of pairs (i, j) such that i < j and ai > aj. Find the expected number of inversions after we apply exactly one operation mentioned above.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the length of the permutation.

The second line contains n distinct integers from 1 to n — elements of the permutation.

Output

Print one real value — the expected number of inversions. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 9. 

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Example

Input

3
2 3 1


Output

1.916666666666666666666666666667

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long tree[300005], arr[100005], val[100005], temp[100005];
double val2[100005];
void update(long long node, long long l, long long r, long long pos,
            long long value) {
  if (l == r && l == pos) {
    tree[node] = value;
    return;
  }
  if (pos > r || pos < l || l > r) return;
  update(node * 2, l, (l + r) / 2, pos, value);
  update(node * 2 + 1, (l + r) / 2 + 1, r, pos, value);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}
long long query(long long node, long long l, long long r, long long i,
                long long j) {
  if (i > r || j < l || l > r)
    return 0;
  else if (l >= i && r <= j)
    return tree[node];
  long long left = query(node * 2, l, (l + r) / 2, i, j);
  long long right = query(node * 2 + 1, (l + r) / 2 + 1, r, i, j);
  return left + right;
}
double inv;
void mergesort(long long l, long long r) {
  if (l == r) return;
  mergesort(l, (l + r) / 2);
  mergesort((l + r) / 2 + 1, r);
  long long i = l, j = (l + r) / 2 + 1, k = 0;
  while (i <= (l + r) / 2 && j <= r) {
    if (arr[i] < arr[j]) {
      temp[k] = arr[i];
      i++;
      k++;
    } else {
      temp[k] = arr[j];
      j++;
      k++;
      inv += (l + r) / 2 - i + 1;
    }
  }
  while (i <= (l + r) / 2) {
    temp[k] = arr[i];
    k++;
    i++;
  }
  while (j <= r) {
    temp[k] = arr[j];
    j++;
    k++;
  }
  k = 0;
  for (i = l; i <= r; i++) {
    arr[i] = temp[k];
    k++;
  }
}
int main() {
  long long i, j, k;
  long long n;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  val[1] = 0;
  val2[1] = 0;
  update(1, 1, n, arr[1], 1);
  for (i = 2; i <= n; i++) {
    val[i] = val[i - 1] + query(1, 1, n, 1, arr[i]);
    val2[i] = val2[i - 1] + (double)(1ll * i * (i - 1)) / 4.0;
    update(1, 1, n, arr[i], i);
  }
  double ans = 0;
  for (i = 1; i <= n; i++) {
    ans += (double)val[i];
    ans -= val2[i];
  }
  ans /= (1ll * n * (n + 1)) / 2;
  inv = 0;
  mergesort(1, n);
  ans = inv + ans;
  printf("%0.10lf\n", ans);
  return 0;
}