#include <bits/stdc++.h>
using namespace std;
const int size = 1e6 + 7;
const int mod = 1e9 + 7;
int p[size];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int n, i, j, x;
  long long ans = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    ans += 2 * (i - p[x]) * 1ll * (n - i + 1) - 1;
    p[x] = i;
  }
  cout << setprecision(6) << fixed;
  cout << (1.0 * ans) / (n * 1ll * n);
  return 0;
}
