#include <bits/stdc++.h>
using namespace std;
int pos[1000006];
int arr[1000006];
long long tot[1000006];
int main() {
  double res = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    int now = i - pos[arr[i]];
    long long r = n - i + 1;
    res += now * 1LL * r * 2 - 1;
    pos[arr[i]] = i;
  }
  printf("%.10lf", res / (n * 1LL * n));
}
