#include <bits/stdc++.h>
using namespace std;
long long ara[1000005], pos[1000005];
long long func(long long n) { return (n * (n + 1)) / 2; }
int main() {
  long long i, j, k;
  long long n, sm;
  scanf("%lld", &n);
  for (i = 0; i < n; ++i) scanf("%lld", &ara[i]);
  for (i = 0; i < 1000005; ++i) pos[i] = -1;
  for (i = 0, sm = 0; i < n; ++i) sm += func(i + 1) + func(n - i) - 1;
  for (i = 0; i < n; ++i) {
    if (pos[ara[i]] != -1) sm -= 2LL * (pos[ara[i]] + 1) * (n - i);
    pos[ara[i]] = i;
  }
  double ans = (double)sm / (double)(n * n);
  printf("%0.8lf\n", ans);
}
