#include <bits/stdc++.h>
using namespace std;
int n, la[1000005], ta;
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ta);
    ans += (long long)(i - la[ta]) * (n - i + 1) * 2 - 1;
    la[ta] = i;
  }
  printf("%.10lf\n", (double)ans / n / n);
  return 0;
}
