#include <bits/stdc++.h>
using namespace std;
typedef struct data {
  int x, y;
  double c;
} data;
data d[100010];
double a[100010];
int sz[100010];
int root[100010];
bool func(const data& a, const data& b) { return a.c > b.c; }
int fd(int x) { return (x == root[x]) ? x : (root[x] = fd(root[x])); }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    root[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    cin >> d[i].x >> d[i].y;
    d[i].c = min(a[d[i].x], a[d[i].y]);
  }
  sort(d, d + m, func);
  double ans = 0;
  for (int i = 0; i < m; i++) {
    int lr, rr;
    lr = fd(d[i].x);
    rr = fd(d[i].y);
    if (lr != rr) {
      ans += d[i].c * sz[lr] * sz[rr];
      sz[lr] += sz[rr];
      root[rr] = lr;
    }
  }
  printf("%0.6f\n", ans * 2 / n / (n - 1));
}
