#include <bits/stdc++.h>
using namespace std;
long double total = 0;
vector<pair<int, int> > nodes(100000);
vector<vector<int> > edges(100000, vector<int>(0));
int parent[100000];
int size[100000];
int last;
int n, m;
void make_set(int node) { parent[node] = node; }
int find_set(int node) {
  if (parent[node] == node) {
    return node;
  }
  return parent[node] = find_set(parent[node]);
}
void link_set(int node1, int node2) {
  if (node1 == node2) {
    return;
  }
  if (size[node1] < size[node2]) {
    swap(node1, node2);
  }
  long double temp = last;
  temp /= n;
  temp *= size[node1];
  temp /= n - 1;
  temp *= size[node2];
  total += temp;
  size[node1] += size[node2];
  parent[node2] = node1;
}
void union_set(int node1, int node2) {
  link_set(find_set(node1), find_set(node2));
}
void add_edges(int node) {
  for (int i = 0; i < edges[node].size(); i++) {
    union_set(node, edges[node][i]);
  }
}
int main(int argc, const char* argv[]) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    pair<int, int> p;
    scanf("%d", &p.first);
    p.second = i;
    nodes[i] = p;
    make_set(i);
    size[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    if (nodes[a].first < nodes[b].first) {
      swap(a, b);
    }
    edges[b].push_back(a);
  }
  sort(nodes.begin(), nodes.begin() + n);
  for (int i = n - 1; i >= 0; i--) {
    last = nodes[i].first;
    add_edges(nodes[i].second);
  }
  cout << total * 2 << endl;
  return 0;
}
