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:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().run(in, out);
        out.close();
    }

    public static long mod = 17352642619633L;

    void run(FastScanner in, PrintWriter out) {

        int N = in.nextInt();
        int[] a = new int[N];

        for (int i = 0; i < N; i++) a[i] = in.nextInt();

        ST st = new ST(N);

        int[] lastSeenPos = new int[1_000_001];
        Arrays.fill(lastSeenPos, -1);

        long sum = 0;
        for (int i = 0; i < N; i++) {
            int n = a[i];

            st.add(1, lastSeenPos[n]+1, i-1);
            sum += 2*st.st[1];

            st.add(1, i, i);
            sum++;

            lastSeenPos[n] = i;
        }
        long pairs = (long)N*N;
        out.println((double)sum/pairs);

    }

    class ST {
        long[] st;
        int[] delta;
        int[] lo;
        int[] hi;
        ST(int N) {
            st = new long[N<<2];
            lo = new int[N<<2];
            hi = new int[N<<2];
            delta = new int[N<<2];
            getBounds(1, 0, N-1);
        }
        void getBounds(int i, int a, int b) {
            lo[i] = a;
            hi[i] = b;
            if (a == b) return;
            int m = (a+b)>>1;
            getBounds(i<<1, a, m);
            getBounds(i<<1|1, m+1, b);
        }

        void add(int i, int a, int b) {
            if (b < lo[i] || a > hi[i]) return;
            if (a <= lo[i] && hi[i] <= b) {
                delta[i] += 1;
                st[i] += (hi[i]-lo[i]+1);
                return;
            }
            prop(i);
            add(i<<1, a, b);
            add(i<<1|1, a, b);
            st[i] = st[i<<1]+st[i<<1|1];
        }

        void prop(int i) {
            if (delta[i] == 0) return;
            delta[i<<1] += delta[i];
            st[i<<1] += delta[i] * (hi[i<<1]-lo[i<<1]+1);

            delta[i<<1|1] += delta[i];
            st[i<<1|1] += delta[i] * (hi[i<<1|1]-lo[i<<1|1]+1);

            delta[i] = 0;
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}