#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 24;
int root[maxn], height[maxn], a[maxn], n, m;
struct node {
  int u, v, w;
  bool operator<(const node& nn) const { return w > nn.w; }
} p[maxn];
int Find(int x) { return root[x] == x ? x : root[x] = Find(root[x]); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    root[i] = i;
    height[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &p[i].u, &p[i].v);
    p[i].w = min(a[p[i].u], a[p[i].v]);
  }
  sort(p + 1, p + m + 1);
  double ans = 0;
  for (int i = 1; i <= m; i++) {
    int tx = Find(p[i].u), ty = Find(p[i].v);
    if (tx != ty) {
      root[tx] = ty;
      ans += (double)p[i].w * height[tx] * height[ty];
      height[ty] += height[tx];
    }
  }
  printf("%.6f\n", (ans * 2) / (n * 1.0 * (n - 1)));
  return 0;
}
