#include <bits/stdc++.h>
namespace Myns {
namespace iostream_ {
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::ios;
}  // namespace iostream_
namespace iomanip_ {
using std::fixed;
using std::setprecision;
}  // namespace iomanip_
namespace string_ {
using std::getline;
using std::string;
}  // namespace string_
namespace algorithm_ {
using std::fill;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::nth_element;
using std::sort;
using std::stable_sort;
}  // namespace algorithm_
namespace utility_ {
using std::make_pair;
using std::pair;
using std::swap;
}  // namespace utility_
namespace array_ {
using std::array;
}
namespace vector_ {
using std::vector;
}
namespace list_ {
using std::list;
}
namespace forward_list_ {
using std::forward_list;
}
namespace deque_ {
using std::deque;
}
namespace stack_ {
using std::stack;
}
namespace queue_ {
using std::priority_queue;
using std::queue;
}  // namespace queue_
namespace set_ {
using std::multiset;
using std::set;
}  // namespace set_
namespace unordered_set_ {
using std::unordered_multiset;
using std::unordered_set;
}  // namespace unordered_set_
namespace map_ {
using std::map;
using std::multimap;
}  // namespace map_
namespace unordered_map_ {
using std::unordered_map;
using std::unordered_multimap;
}  // namespace unordered_map_
namespace iterator_ {
using std::advance;
}
namespace IO {
using namespace iostream_;
using namespace iomanip_;
using namespace string_;
}  // namespace IO
namespace Containers {
using namespace array_;
using namespace vector_;
using namespace list_;
using namespace forward_list_;
using namespace deque_;
using namespace stack_;
using namespace queue_;
using namespace set_;
using namespace unordered_set_;
using namespace map_;
using namespace unordered_map_;
}  // namespace Containers
namespace Utilities {
using namespace utility_;
using namespace algorithm_;
using namespace iterator_;
}  // namespace Utilities
using namespace IO;
using namespace Containers;
using namespace Utilities;
}  // namespace Myns
using namespace Myns;
constexpr int MAX_V = 1000009;
int c[MAX_V];
int p[MAX_V], q[MAX_V];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &ai : a) cin >> ai;
  int uniq = 0;
  int64_t uniq_sum = 0;
  for (int i = 0; i < n; ++i) {
    uniq += (c[a[i]] == 0);
    uniq_sum += uniq;
    ++c[a[i]];
  }
  for (int i = n - 1; i >= 0; --i) {
    if (q[a[i]] == 0) {
      p[i] = n;
      q[a[i]] = i;
    } else {
      p[i] = q[a[i]];
      q[a[i]] = i;
    }
  }
  int64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += uniq_sum * 2 - 1;
    uniq_sum -= (p[i] - i);
  }
  cout << fixed << setprecision(6) << (double)ans / n / n << endl;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

You are given an array a consisting of n positive integers. You pick two integer numbers l and r from 1 to n, inclusive (numbers are picked randomly, equiprobably and independently). If l > r, then you swap values of l and r. You have to calculate the expected value of the number of unique elements in segment of the array from index l to index r, inclusive (1-indexed).

Input

The first line contains one integer number n (1 ≤ n ≤ 106). The second line contains n integer numbers a1, a2, ... an (1 ≤ ai ≤ 106) — elements of the array.

Output

Print one number — the expected number of unique elements in chosen segment. 

Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image>, where x is jury's answer, and y is your answer.

Examples

Input

2
1 2


Output

1.500000


Input

2
2 2


Output

1.000000

### Response

```cpp
#include <bits/stdc++.h>
namespace Myns {
namespace iostream_ {
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::ios;
}  // namespace iostream_
namespace iomanip_ {
using std::fixed;
using std::setprecision;
}  // namespace iomanip_
namespace string_ {
using std::getline;
using std::string;
}  // namespace string_
namespace algorithm_ {
using std::fill;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::nth_element;
using std::sort;
using std::stable_sort;
}  // namespace algorithm_
namespace utility_ {
using std::make_pair;
using std::pair;
using std::swap;
}  // namespace utility_
namespace array_ {
using std::array;
}
namespace vector_ {
using std::vector;
}
namespace list_ {
using std::list;
}
namespace forward_list_ {
using std::forward_list;
}
namespace deque_ {
using std::deque;
}
namespace stack_ {
using std::stack;
}
namespace queue_ {
using std::priority_queue;
using std::queue;
}  // namespace queue_
namespace set_ {
using std::multiset;
using std::set;
}  // namespace set_
namespace unordered_set_ {
using std::unordered_multiset;
using std::unordered_set;
}  // namespace unordered_set_
namespace map_ {
using std::map;
using std::multimap;
}  // namespace map_
namespace unordered_map_ {
using std::unordered_map;
using std::unordered_multimap;
}  // namespace unordered_map_
namespace iterator_ {
using std::advance;
}
namespace IO {
using namespace iostream_;
using namespace iomanip_;
using namespace string_;
}  // namespace IO
namespace Containers {
using namespace array_;
using namespace vector_;
using namespace list_;
using namespace forward_list_;
using namespace deque_;
using namespace stack_;
using namespace queue_;
using namespace set_;
using namespace unordered_set_;
using namespace map_;
using namespace unordered_map_;
}  // namespace Containers
namespace Utilities {
using namespace utility_;
using namespace algorithm_;
using namespace iterator_;
}  // namespace Utilities
using namespace IO;
using namespace Containers;
using namespace Utilities;
}  // namespace Myns
using namespace Myns;
constexpr int MAX_V = 1000009;
int c[MAX_V];
int p[MAX_V], q[MAX_V];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &ai : a) cin >> ai;
  int uniq = 0;
  int64_t uniq_sum = 0;
  for (int i = 0; i < n; ++i) {
    uniq += (c[a[i]] == 0);
    uniq_sum += uniq;
    ++c[a[i]];
  }
  for (int i = n - 1; i >= 0; --i) {
    if (q[a[i]] == 0) {
      p[i] = n;
      q[a[i]] = i;
    } else {
      p[i] = q[a[i]];
      q[a[i]] = i;
    }
  }
  int64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += uniq_sum * 2 - 1;
    uniq_sum -= (p[i] - i);
  }
  cout << fixed << setprecision(6) << (double)ans / n / n << endl;
}

```