#include <bits/stdc++.h>
using namespace std;
const int inf = 0x20202020;
const int mod = 1000000007;
inline void read(int &x) {
  char ch;
  bool f = 0;
  int a = 0;
  while (!((((ch = getchar()) >= '0') && (ch <= '9')) || (ch == '-')))
    ;
  if (ch != '-')
    a *= 10, a += ch - '0';
  else
    f = 1;
  while (((ch = getchar()) >= '0') && (ch <= '9')) a *= 10, a += ch - '0';
  if (f) a = -a;
  x = a;
}
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 111111, M = 111111;
int l, m, n, t, v[N], f[N], sz[N];
struct zcc {
  int l, r, v, x, u;
} a[N];
inline bool cmp(const zcc &a, const zcc &b) { return a.v < b.v; }
int getf(int x) {
  if (x == f[x]) return x;
  return f[x] = getf(f[x]);
}
double ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &v[i]);
  for (int i = 1; i <= m; ++i)
    scanf("%d%d", &a[i].l, &a[i].r), a[i].v = min(v[a[i].l], v[a[i].r]),
                                     a[i].x = i;
  sort(a + 1, a + 1 + m, cmp);
  for (int i = 1; i <= n; ++i) f[i] = i, sz[i] = 1;
  for (int i = m; i >= 1; --i)
    if (getf(a[i].l) != getf(a[i].r))
      f[getf(a[i].l)] = getf(a[i].r);
    else
      a[i].u = 1;
  for (int i = 1; i <= n; ++i) f[i] = i, sz[i] = 1;
  for (int i = m; i >= 1; --i)
    if (!a[i].u) {
      int x = getf(a[i].l), y = getf(a[i].r);
      ans += 1.0 * sz[y] * sz[x] * a[i].v;
      f[x] = y;
      sz[y] += sz[x];
    }
  printf("%.9lf\n", ans / n / (n - 1) * 2);
  return 0;
}
