#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, ed, a[200005], b[200005];
int l[200005], qd[200005], qn[200005], p[200005], v[200005], sz[200005];
long long int ret;
void bd(int x, int y) { qd[++ed] = y, qn[ed] = l[x], l[x] = ed; }
bool cmp(int x, int y) { return a[x] > a[y]; }
int find(int x) {
  if (p[x] == x) return x;
  return p[x] = find(p[x]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (n); i++) {
    scanf("%d", &a[i]);
    b[i] = p[i] = i;
    sz[i] = 1;
    v[i] = 0;
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    x--, y--;
    bd(x, y), bd(y, x);
  }
  sort(b, b + n, cmp);
  for (int i = (0); i < (n); i++) {
    int x = b[i], y, w = a[x];
    v[x] = 1;
    for (int j = (l[x]); j; j = qn[j]) {
      y = qd[j];
      if (!v[y]) continue;
      int xx = find(x), yy = find(y);
      if (xx == yy) continue;
      ret += w * 1LL * sz[xx] * 1LL * sz[yy];
      p[xx] = yy;
      sz[yy] += sz[xx];
    }
  }
  double div = n * (n - 1.) * .5;
  printf("%.7f\n", ret / div);
  return 0;
}
