#include <bits/stdc++.h>
using namespace std;
long long int dsu[200001], rnk[200001];
void make_set(long long int x) {
  dsu[x] = x;
  rnk[x] = 1;
}
long long int find_set(long long int x) {
  if (dsu[x] == x) return x;
  return dsu[x] = find_set(dsu[x]);
}
void union_set(long long int a, long long int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (rnk[a] < rnk[b]) swap(a, b);
    dsu[b] = a;
    rnk[a] += rnk[b];
  }
}
bool f(pair<long long int, long long int> a,
       pair<long long int, long long int> b) {
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int a[n + 1];
  vector<pair<long long int, long long int> > v;
  for (long long int i = 1; i < n + 1; i++) {
    cin >> a[i];
    v.push_back(make_pair((a[i]), (i)));
  }
  vector<long long int> adj[n + 1];
  for (long long int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  sort((v).begin(), (v).end(), f);
  long long int num = 0, den = 0, vis[n + 1];
  memset(vis, 0, sizeof(vis));
  for (auto vi : v) {
    long long int node = vi.second;
    make_set(node);
    vis[node] = 1;
    for (auto to : adj[node])
      if (vis[to] && find_set(node) != find_set(to)) {
        num += (vi.first * rnk[find_set(node)] * rnk[find_set(to)]);
        den += (rnk[find_set(node)] * rnk[find_set(to)]);
        union_set(node, to);
      }
  }
  cout << fixed << setprecision(12) << (long double)num / den << "\n";
  return 0;
}
