Problem: You are given an array a consisting of n positive integers. You pick two integer numbers l and r from 1 to n, inclusive (numbers are picked randomly, equiprobably and independently). If l > r, then you swap values of l and r. You have to calculate the expected value of the number of unique elements in segment of the array from index l to index r, inclusive (1-indexed).

Input

The first line contains one integer number n (1 ≤ n ≤ 106). The second line contains n integer numbers a1, a2, ... an (1 ≤ ai ≤ 106) — elements of the array.

Output

Print one number — the expected number of unique elements in chosen segment. 

Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image>, where x is jury's answer, and y is your answer.

Examples

Input

2
1 2


Output

1.500000


Input

2
2 2


Output

1.000000

Solution (in JAVA):

Solution:
/*
	In this question, we need to find the expected value of number of unique elements
	in a segment of the array from l to r. So for this I have created prefix array
	which keeps track of number of unique elements in all the subarrays ending ending
	at index i. I have also used a hashmap to keep track of last occurence of each
	number. At each index only that particular number will increment the contribution
	to unique numbers till it's previous occurence. So
	pre[i] = pre[i-1] + (i+1) if a[i] is occuring first time.
	pre[i] = pre[i-1] + (i-map.get(a[i])) to get the number of subarrays it will make
	contribution to.
	Once I got prefix array, I calculated the complete sum of pre. I need to twice it.
	Since l -> r & r -> l are considered same. But in this case I am calculating twice
	when l==r. Subtracting n from the value. Dividing the result with n*n to get the
	expection.
	ans = (2*sum-n)/(n*n)
*/
import java.util.*;
public class Q10_RandomQuery {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> map = new HashMap<>();
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		long pre[] = new long[n];
		pre[0] = 1;
		map.put(a[0], 0);
		long sum = pre[0];
		for (int i = 1; i < n; i++) {
			if (map.containsKey(a[i])) {
				pre[i] = pre[i - 1] + (long)(i - map.get(a[i]));
			} else {
				pre[i] = pre[i - 1] + (long)(i + 1);
			}
			map.put(a[i], i);
			sum += pre[i];
		}
		//System.out.println(sum);
		long temp_n = (long)n;
		double val_num = (double)(2 * sum - temp_n);
		double val_den = (double)(temp_n * temp_n);
		System.out.println(String.format("%.6f", val_num / val_den));
	}
}