#include <bits/stdc++.h>
using namespace std;
struct Set {
  int head, tail, size;
  Set(int x) {
    head = x;
    tail = x;
    size = 1;
  }
  Set() { head = tail = size = 0; }
} s[100005];
int a[100005], Next[100005], head[100005];
void MakeSet(int x) {
  s[x] = Set(x);
  head[x] = x;
  Next[x] = -1;
}
int FindSet(int x) { return head[x]; }
void Union(int x, int y) {
  if (s[x].size == 0 || s[y].size == 0) return;
  if (s[x].size < s[y].size) swap(x, y);
  Next[s[x].tail] = s[y].head;
  s[x].tail = s[y].tail;
  s[x].size += s[y].size;
  head[s[y].tail] = s[x].head;
  for (int node = s[y].head; node != s[y].tail; node = Next[node])
    head[node] = s[x].head;
}
bool mark[100005];
pair<int, int> p[100005];
vector<int> v[100005];
long long comb(long long n) {
  if (n % 2 == 0)
    return n / 2 * (n - 1);
  else
    return (n - 1) / 2 * n;
}
long long f(int x) {
  long long ans = 0;
  mark[x] = true;
  vector<int> size;
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i];
    int yn = FindSet(y), xn = FindSet(x);
    if (mark[y] && yn != xn) {
      size.push_back(s[yn].size);
      Union(xn, yn);
    }
  }
  ans = comb(s[FindSet(x)].size - 1);
  for (int i = 0; i < size.size(); i++) ans += size[i] - comb(size[i]);
  return ans;
}
int main() {
  long long n, m, x, y, sum = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    MakeSet(i);
    cin >> a[i];
    p[i].first = a[i];
    p[i].second = i;
  }
  sort(p, p + n);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = n - 1; i >= 0; i--) sum += f(p[i].second) * p[i].first;
  printf("%0.6f\n", double(sum) / comb(n));
  return 0;
}
