#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
int p[NMAX], r[NMAX], sz[NMAX];
int find(const int i) { return (p[i] == i) ? i : (p[i] = find(p[i])); }
void unio(const int x, const int y) {
  if (r[x] > r[y]) {
    p[y] = x;
    sz[x] += sz[y];
  } else {
    p[x] = y;
    sz[y] += sz[x];
    if (r[x] == r[y]) {
      r[y]++;
    }
  }
}
int a[NMAX];
pair<int, pair<int, int>> e[NMAX];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    p[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    e[i].first = min(a[u], a[v]);
    e[i].second.first = u;
    e[i].second.second = v;
  }
  sort(e, e + m, greater<pair<int, pair<int, int>>>());
  double ans = 0.0;
  for (int i = 0; i < m; i++) {
    const int u = e[i].second.first;
    const int v = e[i].second.second;
    const int x = find(u);
    const int y = find(v);
    if (x != y) {
      ans += 2.0 * e[i].first * sz[x] * sz[y];
      unio(x, y);
    }
  }
  printf("%.6lf", ans / n / (n - 1));
  return 0;
}
