#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-6;
struct edge {
  int u, v, cost;
  edge() {}
  edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
} e[100005];
inline bool operator<(const edge &ea, const edge &eb) {
  return ea.cost > eb.cost;
}
struct DJS {
  int boss[100005];
  int member[100005];
  DJS() {
    for (int i = 0; i < 100005; i++) {
      boss[i] = i;
      member[i] = 1;
    }
  }
  int find(int x) { return boss[x] = (boss[x] == x ? x : find(boss[x])); }
} djs;
int v[100005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", v + i);
  for (int j = 0; j < m; j++) {
    int a, b;
    scanf("%d %d", &a, &b);
    e[j] = edge(a, b, min(v[a], v[b]));
  }
  sort(e, e + m);
  double sum = 0.0;
  for (int j = 0; j < m; j++) {
    int bx = djs.find(e[j].u);
    int by = djs.find(e[j].v);
    if (bx == by) continue;
    sum += 2.0 * e[j].cost * djs.member[bx] * djs.member[by];
    djs.member[bx] += djs.member[by];
    djs.boss[by] = bx;
  }
  printf("%.4lf\n", sum / (n * (n - 1.0)));
  return 0;
}
