#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2 * 1000 * 100 + 10;
long long a[MAX_N], parent[MAX_N], child[MAX_N];
vector<pair<long long, pair<int, int> > > edge;
long long ans = 0;
int find_par(int x) {
  if (parent[x] == x) return x;
  return parent[x] = find_par(parent[x]);
}
void merge(int v, int u, long long x) {
  v = find_par(v), u = find_par(u);
  if (v == u) return;
  if (child[v] > child[u]) swap(v, u);
  ans += child[u] * child[v] * x;
  child[u] += child[v];
  parent[v] = u;
}
int main() {
  long long n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    child[i] = 1;
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    edge.push_back(make_pair(min(a[x], a[y]), make_pair(x, y)));
  }
  sort(edge.begin(), edge.end());
  for (int i = m - 1; i >= 0; i--) {
    merge(edge[i].second.first, edge[i].second.second, edge[i].first);
  }
  cout << fixed << setprecision(6);
  cout << (double)(ans * 2) / (double)(n * (n - 1)) << endl;
  return 0;
}
