#include <bits/stdc++.h>
using namespace std;
int t[1000005], n, x;
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
int main() {
  long long ans = 0;
  int i;
  n = read();
  for (i = 1; i <= n; i++) {
    x = read();
    ans += 2ll * (((long long)(i - t[x])) * ((long long)(n - i + 1)));
    t[x] = i;
    ans--;
  }
  double res = 1.0 * ans / n / n;
  printf("%.12lf\n", res);
  return 0;
}
