#include <bits/stdc++.h>
using namespace std;
class DSU {
 public:
  vector<int> c, size, rank;
  DSU(int n) : c(n + 1), size(n + 1, 1), rank(n + 1, 0) {
    for (int i = 1; i <= n; i++) c[i] = i;
  }
  int find(int x) {
    if (c[x] == x) return x;
    return c[x] = find(c[x]);
  }
  void merge(int a, int b) {
    int _a = find(a), _b = find(b);
    if (_a == _b) return;
    if (rank[_a] > rank[_b]) swap(_a, _b);
    c[_b] = _a;
    size[_a] += size[_b];
    rank[_a]++;
  }
};
int n, m;
vector<int> g[111111];
int a[111111];
bool visited[111111];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  while (m--) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  DSU dsu = DSU(n);
  vector<pair<int, int>> v;
  for (int i = 1; i <= n; i++) v.push_back(pair<int, int>(a[i], i));
  sort(v.begin(), v.end(), greater<pair<int, int>>());
  long long tot = 0;
  for (int e = 0; e < n; e++) {
    int here = v[e].second;
    set<int> set;
    for (int i = 0; i < g[here].size(); i++) {
      int there = g[here][i];
      if (visited[there]) {
        set.insert(dsu.find(there));
      }
    }
    long long w = 0;
    long long sq = 0;
    for (auto it = set.begin(); it != set.end(); it++) {
      w += dsu.size[*it];
      sq += (long long)dsu.size[*it] * dsu.size[*it];
    }
    w = (w * w - sq) / 2 + w;
    tot += w * a[here];
    visited[here] = true;
    for (auto it = set.begin(); it != set.end(); it++) dsu.merge(*it, here);
  }
  cout.precision(10);
  cout << (long double)2 * tot / n / (n - 1);
}
