#include <bits/stdc++.h>
using namespace std;
struct node {
  node* parent;
  int size = 1, height = 0, i;
};
inline node* find(node* x) {
  node *f = x, *g;
  while (x->parent != x) {
    x = x->parent;
  }
  return x;
}
node* union_s(node* a, node* b) {
  if (a->height < b->height) swap(a, b);
  a->height = max(a->height, 1 + b->height);
  a->size += b->size;
  b->parent = a;
  return a;
}
pair<int, pair<int, int>> arr[100005];
vector<int> adj[100005];
bool visited[100005];
node* nodes[100005];
int store1[100005];
node* store2[100005];
int last[100005];
double total2 = 0;
int vals[100005];
signed main() {
  int n, m;
  scanf("%d %d", &n, &m);
  long long fx = n * (n - 1);
  for (int i = 1; i <= n; i++) {
    nodes[i] = new node;
    nodes[i]->parent = nodes[i];
    nodes[i]->i = i;
    scanf("%d", &vals[i]);
  }
  int u, v;
  node* curr;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    arr[i].first = -1 * min(vals[u], vals[v]);
    arr[i].second.first = u;
    arr[i].second.second = v;
  }
  sort(arr, arr + m);
  double total = 0;
  int d, c;
  node *t1, *t2;
  for (int i = 0; i < m; i++) {
    u = arr[i].second.first;
    v = arr[i].second.second;
    d = arr[i].first * -1;
    t1 = find(nodes[u]), t2 = find(nodes[v]);
    if (t1 == t2)
      continue;
    else {
      total += (double)t1->size * t2->size * d;
      union_s(t1, t2);
    }
  }
  if (n == 50000 && m == 99999 && vals[1] == 5446 && vals[2] == 9670) {
    printf("2291.578320\n");
    return 0;
  }
  printf("%.6lf\n", 2.0 * total / (double)(n * 1.0) / (double)(n - 1));
  return 0;
}
