#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x *= 10;
    x += ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, cnt, f[100005], fa[100005];
long long size[100005];
long long ans;
struct data1 {
  int x, y, v;
} a[100005];
inline bool cmp(data1 a, data1 b) { return a.v > b.v; }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) f[i] = read(), fa[i] = i, size[i] = 1;
  for (int i = 1; i <= m; i++) {
    a[i].x = read();
    a[i].y = read();
    a[i].v = min(f[a[i].x], f[a[i].y]);
  }
  sort(a + 1, a + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int x = find(a[i].x), y = find(a[i].y);
    if (x != y) {
      ans += a[i].v * size[x] * size[y];
      size[x] += size[y];
      fa[y] = x;
    }
  }
  long long tmp = (long long)n * (n - 1) / 2;
  double ans2 = (double)ans / tmp;
  printf("%.6lf", ans2);
  return 0;
}
