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;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
pair<long long int, long long int> extended_euclid(long long int a,
                                                   long long int b) {
  if (b == 0)
    return pair<long long int, long long int>(1, 0);
  else {
    pair<long long int, long long int> d = extended_euclid(b, a % b);
    return pair<long long int, long long int>(d.second,
                                              d.first - d.second * (a / b));
  }
}
long long int modular_inverse(long long int a, long long int m) {
  pair<long long int, long long int> ret = extended_euclid(a, m);
  return ((ret.first % m) + m) % m;
}
const int mod = 1000000007;
long long int sum[100000 + 7], n, arr[100000 + 7];
long long int tree[4 * 100000 + 7];
long long int tree2[4 * 100000 + 7];
long long int update(int node, int base, int top, int p, long long int val) {
  if (base > p or top < p) return tree[node];
  if (base == top) {
    return tree[node] = val;
  }
  int left, right, mid;
  left = 2 * node;
  right = left + 1;
  mid = (base + top) / 2;
  tree[node] = update(left, base, mid, p, val);
  tree[node] += update(right, mid + 1, top, p, val);
  return tree[node];
}
long long int query(int node, int base, int top, int i, int j) {
  if (base > j or top < i) return 0;
  if (base >= i and top <= j) return tree[node];
  int left, right, mid;
  left = 2 * node;
  right = left + 1;
  mid = (base + top) / 2;
  long long int ret = query(left, base, mid, i, j);
  ret += query(right, mid + 1, top, i, j);
  return ret;
}
double cal_exp(long long int num) {
  long long int res1 = num * (num + 1) * (2 * num + 1);
  res1 /= 6;
  long long int res2 = num * (num + 1);
  res2 /= 2;
  long long int ret = res1 - res2;
  double res = (double)ret / 4.0;
  return res;
}
long long int update2(int node, int base, int top, int p) {
  if (base > p or top < p) return tree2[node];
  if (base == top) {
    return tree2[node] = 1;
  }
  int left, right, mid;
  left = 2 * node;
  right = left + 1;
  mid = (base + top) / 2;
  tree2[node] = update2(left, base, mid, p);
  tree2[node] += update2(right, mid + 1, top, p);
  return tree2[node];
}
long long int query2(int node, int base, int top, int i, int j) {
  if (base > j or top < i) return 0;
  if (base >= i and top <= j) return tree2[node];
  int left, right, mid;
  left = 2 * node;
  right = left + 1;
  mid = (base + top) / 2;
  long long int ret = query2(left, base, mid, i, j);
  ret += query2(right, mid + 1, top, i, j);
  return ret;
}
int main() {
  long long int i, j, k;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  double ans = 0.0;
  long long int rem = 0;
  for (i = n; i > 0; i--) {
    sum[i] = sum[i + 1] + query(1, 1, n, 1, arr[i]);
    rem += query2(1, 1, n, 1, arr[i]);
    double ex = cal_exp(n - i + 1);
    ans += ex - (double)sum[i];
    update(1, 1, n, arr[i], n - i + 1);
    update2(1, 1, n, arr[i]);
  }
  long long int val = n * (n + 1);
  ans *= 2.0;
  ans /= (double)val;
  ans += rem;
  printf("%.11f\n", ans);
  return 0;
}