#include <bits/stdc++.h>
using namespace std;
void Fast_Read_Out() {
  ios_base::sync_with_stdio(0);
  cin.tie(), cout.tie();
}
void Random() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
unsigned int Time() {
  unsigned int time = clock() / 1000.00;
  return time;
}
const int mod = (int)1e9 + 7;
const int N = int(1e6) + 213;
int a[N];
int d[N];
int last[N];
int main() {
  Fast_Read_Out();
  Random();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (!d[a[i]])
      last[i] = 0, d[a[i]] = i;
    else {
      last[i] = d[a[i]];
      d[a[i]] = i;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += 1ll * (i - last[i]) * 1ll * (n - i + 1);
  ans *= 2;
  ans -= n;
  cout << (double)ans / (1ll * n * n);
}
