#include <bits/stdc++.h>
const int N = 1000000 + 9;
int n, m, f[N], sz[N], son[N], lnk[N * 2], nxt[N * 2], ec, v[N], t[N], map[N];
long long ans;
int getf(int x) { return x == f[x] ? x : f[x] = getf(f[x]); }
inline bool cmp(const int lhs, const int rhs) { return v[lhs] < v[rhs]; }
inline void addedge(int x, int y) {
  nxt[++ec] = son[x];
  son[x] = ec;
  lnk[ec] = y;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", v + i);
    t[i] = i;
  }
  for (int x, y; m--;) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  std::sort(t + 1, t + 1 + n, cmp);
  for (int i = 1; i <= n; ++i) f[i] = i, sz[i] = 1, map[t[i]] = i;
  for (int k = n; k; --k) {
    int i = t[k];
    for (int j = son[i]; j; j = nxt[j]) {
      if (map[lnk[j]] < map[i]) continue;
      int fx = getf(i), fy = getf(lnk[j]);
      if (fx == fy) continue;
      f[fy] = fx;
      ans += 1ll * sz[fy] * sz[fx] * v[i];
      sz[fx] += sz[fy];
    }
  }
  printf("%.6f\n", ans * 2.0 / (1ll * n * (n - 1)));
}
