#include <bits/stdc++.h>
using namespace std;
struct edge {
  int x, y, w;
  bool operator<(const edge &B) const { return w > B.w; }
} e[100005];
int N, M, a[100005], f[100005], s[100005];
void init() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1, u, v; i <= M; i++) {
    scanf("%d%d", &e[i].x, &e[i].y);
    e[i].w = min(a[e[i].x], a[e[i].y]);
  }
}
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
void doit() {
  sort(e + 1, e + M + 1);
  for (int i = 1; i <= N; i++) {
    f[i] = i;
    s[i] = 1;
  }
  long long ans = 0;
  for (int i = 1; i <= M; i++) {
    int x = find(e[i].x);
    int y = find(e[i].y);
    if (x != y) {
      ans += 1ll * e[i].w * s[x] * s[y];
      f[x] = y;
      s[y] += s[x];
    }
  }
  printf("%.9lf\n", 2.0 * ans / N / (N - 1));
}
int main() {
  init();
  doit();
  return 0;
}
