#include <bits/stdc++.h>
template <class T>
inline void in(T &x) {
  x = 0;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - 48;
}
template <class T>
inline T max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min(T a, T b) {
  return a < b ? a : b;
}
int n, m;
int head[200500], siz[200500], bel[200500], val[200500];
struct Edge {
  int from, to, len;
} edge[200500];
inline bool operator<(const Edge &x, const Edge &y) { return x.len > y.len; }
int find(register int now) {
  return bel[now] == now ? now : bel[now] = find(bel[now]);
}
int main(void) {
  long long tot = 0;
  in(n), in(m);
  int foo, bar;
  for (register int i = 1; i <= n; ++i) in(val[i]), bel[i] = i, siz[i] = 1;
  for (register int i = 1; i <= m; ++i) {
    in(edge[i].from), in(edge[i].to);
    edge[i].len = min(val[edge[i].from], val[edge[i].to]);
  }
  std::sort(edge + 1, edge + 1 + m);
  for (register int i = 1; i <= m; ++i) {
    foo = find(edge[i].from), bar = find(edge[i].to);
    if (foo == bar) continue;
    tot += 1ll * siz[foo] * siz[bar] * edge[i].len;
    bel[foo] = bar, siz[bar] += siz[foo];
  }
  printf("%lf", 1.0 * tot / n / (n - 1) * 2);
}
