#include <bits/stdc++.h>
using namespace std;
const int maxN = 100010;
struct Edge {
  int a, b, val;
  Edge() {}
  Edge(int _a, int _b, int _val) {
    a = _a;
    b = _b;
    val = _val;
  }
};
Edge e[maxN];
int n, m, a[maxN];
int p[maxN], h[maxN], s[maxN];
double sol, k;
bool cmp(const Edge &a, const Edge &b) { return a.val > b.val; }
int sfind(int a) {
  while (p[a]) a = p[a];
  return a;
}
void sunion(int a, int b) {
  int x = sfind(a), y = sfind(b);
  if (h[x] > h[y])
    p[y] = x, s[x] += s[y];
  else {
    p[x] = y;
    s[y] += s[x];
    if (h[x] == h[y]) h[y]++;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  k = (long long)n * (long long)(n - 1) / 2LL;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    e[i] = Edge(x, y, min(a[x], a[y]));
  }
  sort(e + 1, e + m + 1, cmp);
  for (int i = 1; i <= n; i++) s[i] = 1;
  for (int i = 1; i <= m; i++)
    if (sfind(e[i].a) != sfind(e[i].b)) {
      int x = s[sfind(e[i].a)];
      int y = s[sfind(e[i].b)];
      long long z = (long long)x * (long long)y;
      sol += z * (long long)e[i].val;
      sunion(e[i].a, e[i].b);
    }
  printf("%.6lf\n", sol / k);
  return 0;
}
