#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
struct L {
  long long t1, t2;
  long long val;
} l[N * 20];
long long n, m, a[N], fa[N], ans, siz[N];
void read(long long &in) {
  long long x = 0, f = 1;
  char ch;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  in = x * f;
  return;
}
inline long long find(long long x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = find(fa[x]);
}
inline bool cmp(L x, L y) { return x.val > y.val; }
void unite(long long x, long long y) {
  fa[x] = y;
  siz[y] += siz[x];
  return;
}
signed main() {
  read(n);
  read(m);
  for (register long long i = 1; i <= n; i++) {
    read(a[i]);
    fa[i] = i;
    siz[i] = 1;
  }
  for (register long long i = 1; i <= m; i++) {
    read(l[i].t1);
    read(l[i].t2);
    l[i].val = min(a[l[i].t1], a[l[i].t2]);
  }
  sort(l + 1, l + m + 1, cmp);
  long long x, y;
  for (register long long i = 1; i <= m; i++) {
    x = find(l[i].t1);
    y = find(l[i].t2);
    if (x != y) {
      ans += siz[x] * siz[y] * l[i].val;
      unite(x, y);
    }
  }
  long long chus = (long long)n * (n - 1) / 2;
  double fin = (double)ans / chus;
  printf("%.6lf\n", fin);
  return 0;
}
