#include <bits/stdc++.h>
using namespace std;
const int N = 100169;
int n, c[N], f[N], sz[N], k, l;
struct edge {
  int a, b, m;
  bool operator<(const edge &e) const { return m > e.m; }
};
edge e[N];
int Find(int x) { return f[x] == x ? x : f[x] = Find(f[x]); }
int main() {
  int m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> c[i];
  for (int i = 0; i < m; ++i) {
    cin >> k >> l;
    e[i].a = --k;
    e[i].b = --l;
    e[i].m = min(c[k], c[l]);
  }
  for (int i = 0; i < n + 1; ++i) f[i] = i, sz[i] = 1;
  sort(e, e + m);
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    int fa = Find(e[i].a), fb = Find(e[i].b);
    if (fa != fb) {
      ans += 1LL * sz[fa] * sz[fb] * e[i].m;
      sz[fa] += sz[fb];
      f[fb] = fa;
    }
  }
  printf("%.13lf", 2.0 * ans / n / (n - 1));
}
