#include <bits/stdc++.h>
using namespace std;
const long long N = 100000 + 1;
long long n, m, u, v, w, a[N], par[N], SIZE[N], res = 0;
vector<pair<int, pair<int, int> > > edge;
inline long long find_set(long long u) {
  if (par[u] != u) par[u] = find_set(par[u]);
  return par[u];
}
inline void join(long long u, long long v) {
  long long set_u = find_set(u), set_v = find_set(v);
  SIZE[set_u] += SIZE[set_v];
  par[set_v] = set_u;
}
int main() {
  scanf("%d%d", &n, &m);
  for (u = 1; u <= n; u++) {
    scanf("%d", &a[u]);
    par[u] = u;
    SIZE[u] = 1;
  }
  while (m--) {
    scanf("%d%d", &u, &v);
    edge.push_back(
        pair<int, pair<int, int> >(min(a[u], a[v]), pair<int, int>(u, v)));
  }
  sort(edge.rbegin(), edge.rend());
  for (vector<pair<int, pair<int, int> > >::iterator it = edge.begin();
       it != edge.end(); it++) {
    u = it->second.first;
    v = it->second.second;
    w = it->first;
    if (find_set(u) == find_set(v)) continue;
    res += w * SIZE[par[u]] * SIZE[par[v]];
    join(u, v);
  }
  printf("%.7f", (res * 2) / (1.0 * n * (n - 1)));
}
