#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[200005];
long long parent[200005], sz[200005];
vector<pair<pair<int, int>, long long> > edges;
double ans;
int cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.second > b.second;
}
void make_set(int n) {
  for (int i = 0; i < n; i++) {
    sz[i] = 1;
    parent[i] = i;
  }
}
int find(int i) {
  if (parent[i] != i) parent[i] = find(parent[i]);
  return parent[i];
}
void Union(int x, int y, long long wt) {
  int xroot = find(x);
  int yroot = find(y);
  if (xroot == yroot) return;
  parent[xroot] = yroot;
  ans = ans + wt * sz[xroot] * sz[yroot];
  sz[yroot] += sz[xroot];
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  make_set(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    edges.push_back(make_pair(make_pair(x, y), min(a[x], a[y])));
  }
  sort(edges.begin(), edges.end(), cmp);
  for (auto it = edges.begin(); it != edges.end(); ++it) {
    pair<int, int> curp = it->first;
    Union(curp.first, curp.second, it->second);
  }
  ans = ans / (double)(n);
  ans = ans / (double)(n - 1);
  cout << setprecision(10);
  cout << ans * 2 << endl;
  return 0;
}
