#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
struct edge {
  int x, y, v;
  bool operator<(const edge& t) const { return v > t.v; }
} e[maxn];
int w[maxn];
long long f[maxn], sz[maxn];
int findset(int x) { return f[x] == x ? x : f[x] = findset(f[x]); }
int main() {
  int n, m, i, a, b;
  long long ans;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (i = 1; i <= n; ++i) {
    f[i] = i;
    sz[i] = 1;
  }
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &e[i].x, &e[i].y);
    e[i].v = min(w[e[i].x], w[e[i].y]);
  }
  sort(e + 1, e + m + 1);
  ans = 0;
  for (i = 1; i <= m; ++i) {
    a = findset(e[i].x);
    b = findset(e[i].y);
    if (a == b) continue;
    f[a] = b;
    ans += sz[b] * sz[a] * e[i].v;
    sz[b] += sz[a];
  }
  printf("%.6lf\n", ans * 2.0 / n / (n - 1));
  return 0;
}
