#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
int n, m, cost[100010];
vector<int> edges[100010];
bool visited[100010];
int parent[100010], setsize[100010];
int find_parent(int a) {
  if (parent[a] == a) return a;
  return parent[a] = find_parent(parent[a]);
}
void Union(int a, int b) {
  int pa = find_parent(a), push_back = find_parent(b);
  setsize[push_back] += setsize[pa];
  parent[pa] = push_back;
}
int get_size(int a) {
  int pa = find_parent(a);
  return setsize[pa];
}
priority_queue<pair<int, int> > pq;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> cost[i];
    pq.push(make_pair(cost[i], i));
  }
  int a, b;
  for (int i = 0; i < (int)(m); ++i) {
    cin >> a >> b;
    --a, --b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  memset(parent, -1, sizeof(parent));
  for (int i = 0; i < (int)(n); ++i) {
    setsize[i] = 1;
  }
  long long ans = 0, tot;
  while (!pq.empty()) {
    pair<int, int> p = pq.top();
    pq.pop();
    vector<int> v;
    parent[p.second] = p.second;
    tot = 0;
    for (int i = 0; i < (int)(((long long)edges[p.second].size())); ++i) {
      if (parent[edges[p.second][i]] == -1) continue;
      if (find_parent(p.second) == find_parent(edges[p.second][i])) continue;
      v.push_back(get_size(edges[p.second][i]));
      tot += get_size(edges[p.second][i]);
      Union(edges[p.second][i], p.second);
    }
    for (int i = 0; i < (int)(((long long)v.size())); ++i) {
      ans += (tot - v[i]) * v[i] * p.first;
    }
    ans += 2 * tot * p.first;
  }
  cout << fixed << setprecision(6) << double(ans) / double(n) / double(n - 1)
       << endl;
  return 0;
}
