#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
int n, m, a, fa, b, op, F[M], tot[M], val[M];
long long Ans, t;
struct node {
  int a, b, c;
  bool operator<(node _) const { return c > _.c; }
} A[M];
int find(int x) { return x == F[x] ? x : F[x] = find(F[x]); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) cin >> val[i], tot[i] = 1, F[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &A[i].a, &A[i].b);
    A[i].c = min(val[A[i].a], val[A[i].b]);
  }
  sort(A + 1, A + m + 1);
  for (int i = 1; i <= m; i++) {
    int fa = find(A[i].a), fb = find(A[i].b);
    if (fa == fb) continue;
    Ans += 1ll * tot[fa] * tot[fb] * A[i].c;
    t += 1ll * tot[fa] * tot[fb];
    F[fa] = fb, tot[fb] += tot[fa];
  }
  printf("%.6f", (double)Ans / t);
}
