#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
vector<int> vec[MAX];
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 1; i <= 1e6; i++) {
    vec[i].push_back(0);
  }
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    vec[a].push_back(i);
  }
  long long ans = 0;
  for (int i = 1; i <= 1e6; i++) {
    if (vec[i].size() > 1) {
      vec[i].push_back(n + 1);
      long long cur = n * n;
      for (int j = 1; j < vec[i].size(); j++) {
        long long dif = vec[i][j] - vec[i][j - 1] - 1;
        cur -= (dif * dif);
      }
      ans += cur;
    }
  }
  printf("%lf\n", (double)ans / (double)(n * n));
  return 0;
}
