#include <bits/stdc++.h>
using namespace std;
long long pos[1000009];
int main() {
  long long i, j, k, l, m, n, sum = 0;
  cin >> n;
  memset(pos, -1, sizeof pos);
  for (i = 1; i <= n; i++) {
    cin >> l;
    if (pos[l] != -1)
      sum += (2 * (i - pos[l]) * (n - i + 1)) - 1;
    else
      sum += (2 * (i) * (n - i + 1)) - 1;
    pos[l] = i;
  }
  double ans, num;
  num = (double)n;
  num = num * num;
  ans = (double)sum;
  ans = (ans) / num;
  cout << std::setprecision(12) << ans << '\n';
}
