#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6;
long long n, m;
long long s[MAX];
long long p[MAX];
long long sz[MAX];
long long find(long long x) {
  if (p[x] == x) return x;
  return p[x] = find(p[x]);
}
void join(long long a, long long b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  if (rand() & 1) swap(a, b);
  p[a] = b;
  sz[b] += sz[a];
}
struct edge {
  long long u, v, w;
  bool operator<(const edge &o) const { return w > o.w; }
} edges[MAX];
long long E;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < (n); i++) cin >> s[i];
  for (long long i = 0; i < (n); i++) p[i] = i;
  for (long long i = 0; i < (n); i++) sz[i] = 1;
  for (long long i = 0; i < (m); i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    long long w = min(s[u], s[v]);
    edges[E++] = (edge){u, v, w};
  }
  sort(edges, edges + E);
  for (long long i = 0; i < E; i++) {
    long long u = edges[i].u;
    long long v = edges[i].v;
    long long w = edges[i].w;
  }
  long long sum = 0;
  for (long long i = 0; i < E; i++) {
    long long u = edges[i].u;
    long long v = edges[i].v;
    long long w = edges[i].w;
    long long a = find(u);
    long long b = find(v);
    if (a == b) continue;
    long long cnt = sz[a] * sz[b] * w;
    sum = sum + cnt;
    join(a, b);
  }
  cout << setprecision(10) << fixed << 2LL * sum / (double)(n * (n - 1))
       << '\n';
  return 0;
}
