#include <bits/stdc++.h>
using namespace std;
struct Node {
  int num;
  int key;
};
struct Edge {
  int num;
  int next;
};
int f[100001];
bool mark[100001];
long long g[100001];
int find(int k) { return f[k] == k ? k : f[k] = find(f[k]); }
int n, m;
Edge e[200001];
int z;
int p[100001];
Node a[100001];
long long ans, sum1, sum2;
bool cmp(Node x, Node y) { return x.key > y.key; }
void add(int u, int v) {
  z++;
  e[z].num = v;
  e[z].next = p[u];
  p[u] = z;
}
int main() {
  memset(p, -1, sizeof(p));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    g[i] = 1;
    scanf("%d", &a[i].key);
    a[i].num = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int k1, k2;
    scanf("%d%d", &k1, &k2);
    add(k1, k2);
    add(k2, k1);
  }
  for (int i = 1; i <= n; i++) {
    sum1 = sum2 = 0;
    int u = a[i].num;
    int p1, p2;
    mark[u] = true;
    for (int temp = p[u]; temp != -1; temp = e[temp].next) {
      int v = e[temp].num;
      if (!mark[v]) continue;
      p1 = find(v);
      p2 = u;
      if (p1 != p2) {
        sum1 += g[p1];
        sum2 += g[p1] * g[p1];
        f[p1] = p2;
        g[p2] += g[p1];
      }
    }
    ans += a[i].key * (sum1 * sum1 - sum2 + 2 * (g[u] - 1));
  }
  double a1, a2;
  a1 = ans;
  a2 = n;
  a2 *= (a2 - 1);
  printf("%lf", a1 / a2);
  return 0;
}
