#include <bits/stdc++.h>
using namespace std;
const int N = 200002;
long long int a[N];
long long int sz[N];
int par[N];
struct edge {
  int v1, v2;
  long long int wt;
};
bool cmp(edge x, edge y) { return x.wt > y.wt; }
vector<edge> g;
int baap(int node) {
  return par[node] = (node == par[node]) ? node : baap(par[node]);
}
long long int join(int a, int b) {
  int x = baap(a);
  int y = baap(b);
  if (x == y) return 0;
  long long int val = sz[x] * sz[y];
  if (sz[x] >= sz[y]) {
    sz[x] += sz[y];
    par[y] = x;
  } else {
    sz[y] += sz[x];
    par[x] = y;
  }
  return val;
}
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) par[i] = i, sz[i] = 1;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    long long int val = min(a[u], a[v]);
    g.push_back({u, v, val});
  }
  sort(g.begin(), g.end(), cmp);
  long long int sum = 0;
  for (int i = 0; i < g.size(); i++) {
    int u = g[i].v1, v = g[i].v2;
    long long int val = g[i].wt;
    sum += join(u, v) * val;
  }
  double ans = sum;
  ans /= n;
  ans /= n - 1;
  ans += ans;
  cout << setprecision(10) << ans << endl;
  return 0;
}
