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

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void solve() throws IOException {
        int n = readInt();
        int[] a = readIntArray(n);

        out.println(clever(n, a));

//        while (true) {
//            int size = 1 + random.nextInt(10);
//            int[] data = new int[size];
//            for (int i = 0; i < data.length; i++) {
//                data[i] = random.nextInt(5) + 1;
//            }
//            double x = clever(size, data.clone());
//            double y = calc(data);
//            if (Math.abs(x - y) > 1e-6) throw new RuntimeException(Arrays.toString(data));
//        }

    }

    Random random = new Random();

    double clever(int n, int[] a) {
        long allCount = (long) n * n;


        int[] prev = new int[1000 * 1000 + 100];
        Arrays.fill(prev, -1);

        int[] left = new int[n];
        for (int i = 0; i < n; i++) {
            int x = a[i];
            left[i] = prev[x] + 1;
            prev[x] = i;
        }


        int[] right = new int[n];
        Arrays.fill(right, n - 1);

        long sum = 0;
        for (int i = 0; i < n; i++) {
            long count = 2L * (i - left[i]) * ((long)right[i] - i);
            count += (i - left[i]) * 2;
            count += (right[i] - i) * 2;
            count++;
            sum += count;
        }
        return (double) sum / allCount;
    }

    double calc(int[] data) {
        double res = 0;
        for (int i = 0; i < data.length; i++) {
            for (int j = 0; j < data.length; j++) {
                res += uniq(data, i, j);
            }
        }
        return res / (data.length * data.length);
    }

    int uniq(int[] data, int i, int j) {
        if (i > j) return uniq(data, j, i);
        HashSet<Integer> set = new HashSet<>();
        for (int s = i; s <= j; s++) {
            set.add(data[s]);
        }
        return set.size();
    }

}