#include <bits/stdc++.h>
using namespace std;
int b[1000001];
long long int dp[1000001];
int main() {
  long long int n;
  cin >> n;
  int i;
  int a[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  b[a[1]] = 1;
  dp[1] = 1;
  long long int sum = 1;
  for (i = 2; i <= n; i++) {
    int x = a[i];
    dp[i] = 1 + (dp[i - 1] + (i - 1 - b[x]));
    b[x] = i;
    sum += (2 * dp[i]) - 1;
  }
  double ss = sum / (double)(n * n);
  printf("%.7f\n", ss);
  return 0;
}
