#include <bits/stdc++.h>
using namespace std;
int n, m, a[100000], sz[100000], mas[100000], p1, p2;
bool allow[100000];
pair<int, int> node[100000];
vector<int> conn[100000];
long long lconn, cconn, result;
int getmaster(int pos) {
  if (mas[pos] == pos) return pos;
  int ret = getmaster(mas[pos]);
  mas[pos] = ret;
  return ret;
}
void unite(int a, int b) {
  a = getmaster(a), b = getmaster(b);
  if (a == b) return;
  cconn += 2LL * sz[a] * sz[b];
  if (sz[a] > sz[b])
    sz[a] += sz[b], mas[b] = a;
  else
    sz[b] += sz[a], mas[a] = b;
}
int main() {
  cin.sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    cin >> a[i], node[i] = make_pair(a[i], i), mas[i] = i, sz[i] = 1;
  for (int i = 0; i < m; i++) {
    cin >> p1 >> p2;
    p1--, p2--;
    conn[p1].push_back(p2);
    conn[p2].push_back(p1);
  }
  sort(node, node + n);
  reverse(node, node + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < conn[node[i].second].size(); j++)
      if (allow[conn[node[i].second][j]])
        unite(node[i].second, conn[node[i].second][j]);
    result += (cconn - lconn) * node[i].first;
    lconn = cconn;
    allow[node[i].second] = true;
  }
  cout << fixed << setprecision(5) << 1.0 * result / n / (n - 1);
  return 0;
}
