#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int fa[maxn], a[maxn];
long long s[maxn];
int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
struct edge {
  int f, t, v;
};
edge E[maxn];
bool cmp(edge x, edge y) { return x.v > y.v; }
int main() {
  int n, m;
  n = read();
  m = read();
  for (int i = 0; i <= n; i++) {
    fa[i] = i;
    s[i] = 1;
  }
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 0; i < m; i++) {
    E[i].f = read();
    E[i].t = read();
    E[i].v = min(a[E[i].f], a[E[i].t]);
  }
  sort(E, E + m, cmp);
  long long sum = 0;
  for (int i = 0; i < m; i++) {
    int A = Find(E[i].f), B = Find(E[i].t);
    if (A != B) {
      sum += s[A] * s[B] * 2 * E[i].v;
      fa[A] = B;
      s[B] += s[A];
    }
  }
  long long tmp = (long long)n * (n - 1);
  printf("%.6lf\n", double(sum) / tmp);
  return 0;
}
