#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = (long long)1e18;
const double pi = acos(-1.0);
template <class T>
inline T sqr(T a) {
  return a * a;
}
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int pw(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base;
  int tmp = pw(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
const int maxn = 200000;
int N, M, x, y, p[maxn], c[maxn], f[maxn], s[maxn];
long long ans;
bool cmp(const int &a, const int &b) { return c[a] > c[b]; }
vector<int> E[maxn];
int find(int x) {
  if (f[x] == x) return x;
  int t = find(f[x]);
  s[x] += s[f[x]];
  return f[x] = t;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = (1); i <= (N); ++i) scanf("%d", &c[i]);
  for (int i = (1); i <= (M); ++i) {
    scanf("%d%d", &x, &y);
    if (c[x] < c[y])
      E[x].push_back(y);
    else
      E[y].push_back(x);
  }
  for (int i = (1); i <= (N); ++i) p[i] = i;
  sort(p + 1, p + N + 1, cmp);
  for (int i = (1); i <= (N); ++i) f[i] = i, s[i] = 1;
  for (int i = (1); i <= (N); ++i) {
    int S = p[i];
    for (int j = 0; j < E[S].size(); ++j) {
      int x = find(S), y = find(E[S][j]);
      if (x != y) {
        ans += (long long)c[S] * s[x] * s[y];
        f[x] = y;
        s[y] += s[x];
      }
    }
  }
  double ret = ans * 2. / N / (N - 1);
  printf("%.10lf\n", ret);
  return 0;
}
