#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200007;
int n, m, v[MAXN];
struct Edge {
  int from, to, cost;
  bool operator<(const Edge& e) const { return cost > e.cost; }
  Edge() {}
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};
vector<Edge> G;
int fa[MAXN], siz[MAXN];
inline int query(int k) { return (fa[k] == k) ? (k) : (fa[k] = query(fa[k])); }
double ans = 0;
inline void combine(const Edge& e) {
  int u = query(e.from);
  int v = query(e.to);
  if (u == v) return;
  ans += (double)siz[u] * siz[v] * e.cost;
  fa[u] = v;
  siz[u] = siz[v] = siz[u] + siz[v];
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", v + i);
    fa[i] = i;
    siz[i] = 1;
  }
  for (int i = 0, u, v; i < m; ++i) {
    scanf("%d %d", &u, &v);
    G.push_back(Edge(u, v, min(::v[u], ::v[v])));
  }
  sort(G.begin(), G.end());
  for (int i = 0; i < G.size(); ++i) combine(G[i]);
  printf("%.8f\n", ans * 2 / ((double)n * (n - 1)));
  return 0;
}
