#include <bits/stdc++.h>
using namespace std;
long long n, x;
long long ans = 0;
long long pre[1000000 + 5];
long long last[1000000 + 5];
void isi() {
  memset(pre, 0, sizeof pre);
  for (long long i = 1; i <= 1000000; i++) {
    pre[i] = i + pre[i - 1];
  }
  for (long long i = 1; i <= 1000000; i++) {
    pre[i] += pre[i - 1];
  }
  for (long long i = 1; i <= 1000000; i++) {
    pre[i] = pre[i] * 2 - i;
  }
}
int main() {
  memset(last, -1, sizeof last);
  isi();
  scanf("%I64d", &n);
  ans = pre[n];
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &x);
    if (last[x] != -1) {
      ans -= 2 * (n - i + 1) * (last[x]);
    }
    last[x] = i;
  }
  printf("%.6lf\n", (double)ans / n / n);
}
