#include <bits/stdc++.h>
using namespace std;
long long setSize[100000];
long long minVal[100000];
int parent[100000];
list<int> neigh[100000];
int findSet(int a) {
  if (parent[a] == a)
    return a;
  else
    return parent[a] = findSet(parent[a]);
}
void unionSets(int a, int b) {
  a = findSet(a);
  b = findSet(b);
  if (setSize[a] > setSize[b]) {
    parent[b] = a;
    setSize[a] += setSize[b];
    if (minVal[b] < minVal[a]) minVal[a] = minVal[b];
  } else {
    parent[a] = b;
    setSize[b] += setSize[a];
    if (minVal[a] < minVal[b]) minVal[b] = minVal[a];
  }
}
long long arr[100000];
int ind[100000];
void QSort(int l, int r) {
  int x = l, y = r, m = arr[ind[(l + r) / 2]];
  while (x <= y) {
    while (arr[ind[x]] > m) x++;
    while (arr[ind[y]] < m) y--;
    if (x <= y) {
      int t = ind[x];
      ind[x] = ind[y];
      ind[y] = t;
      x++;
      y--;
    }
  }
  if (x < r) QSort(x, r);
  if (l < y) QSort(l, y);
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &arr[i]);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    neigh[u].push_back(v);
    neigh[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    setSize[i] = 1;
    ind[i] = i;
  }
  QSort(0, n - 1);
  for (int i = 0; i < n; i++) {
    minVal[ind[i]] = arr[ind[i]];
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    int v = ind[i];
    for (list<int>::iterator it = neigh[v].begin(); it != neigh[v].end();
         ++it) {
      int t = *it;
      if (findSet(v) != findSet(t) && minVal[findSet(t)] >= arr[v]) {
        ans += arr[v] * setSize[findSet(t)] / double(n) * setSize[findSet(v)] /
               double(n - 1) * 2;
        unionSets(v, t);
      }
    }
  }
  cout << ans << endl;
}
